diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2008-03-20 00:03:48 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2008-03-20 00:03:48 +0000 |
| commit | 14d2057c051cee6e82560b579b5e669b770ba011 (patch) | |
| tree | f96f834b7701e1a4d73d7b0754ac004cb614dca6 /qpid/java/client/example/src | |
| parent | 96247486312f65fafa0f035c9b87f1ed923974e5 (diff) | |
| download | qpid-python-14d2057c051cee6e82560b579b5e669b770ba011.tar.gz | |
This is a fix for QPID-864.
This allows the Listener or Consumer to start multiple instances by taking a JNDI name of a queue bound to the topic exchange as a program argument.
The JNDI name should be defined in the fanout.properties. Currently 3 such queues are defined.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@639090 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/example/src')
3 files changed, 24 insertions, 11 deletions
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java index e813c0ce60..daa1b10b6b 100755 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java @@ -59,16 +59,20 @@ public class Consumer * * @param args Command line arguments. */ - public static void main(String[] args) + public static void main(String[] args) throws Exception { + if (args.length == 0) + { + throw new Exception("You need to specify the JNDI name for the queue"); + } Consumer syncConsumer = new Consumer(); - syncConsumer.runTest(); + syncConsumer.runTest(args[0]); } /** * Start the example. */ - private void runTest() + private void runTest(String queueName) { try { @@ -80,7 +84,7 @@ public class Consumer Context ctx = new InitialContext(properties); // look up destination - Destination destination = (Destination)ctx.lookup("fanoutQueue"); + Destination destination = (Destination)ctx.lookup(queueName); // Lookup the connection factory ConnectionFactory conFac = (ConnectionFactory)ctx.lookup("qpidConnectionfactory"); diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java index 4d645888a3..fb750693b2 100755 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java @@ -39,17 +39,17 @@ public class Listener implements MessageListener /** * An object to synchronize on. */ - private final static Object _lock = new Object(); + private final Object _lock = new Object(); /** * A boolean to indicate a clean finish. */ - private static boolean _finished = false; + private boolean _finished = false; /** * A boolean to indicate an unsuccesful finish. */ - private static boolean _failed = false; + private boolean _failed = false; @@ -58,16 +58,20 @@ public class Listener implements MessageListener * * @param args Command line arguments. */ - public static void main(String[] args) + public static void main(String[] args) throws Exception { + if (args.length == 0) + { + throw new Exception("You need to specify the JNDI name for the queue"); + } Listener listener = new Listener(); - listener.runTest(); + listener.runTest(args[0]); } /** * Start the example. */ - private void runTest() + private void runTest(String queueName) { try { @@ -77,7 +81,7 @@ public class Listener implements MessageListener //Create the initial context Context ctx = new InitialContext(properties); - Destination destination = (Destination)ctx.lookup("fanoutQueue"); + Destination destination = (Destination)ctx.lookup(queueName); // Declare the connection ConnectionFactory conFac = (ConnectionFactory)ctx.lookup("qpidConnectionfactory"); diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties b/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties index bde9ae4dae..0f1dd43aa9 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties @@ -25,4 +25,9 @@ connectionfactory.qpidConnectionfactory = qpid:password=pass;username=name@tcp:l # Register an AMQP destination in JNDI # destination.[jniName] = [BindingURL] +destination.fanoutQueue1 = fanout://amq.fanout//message_queue1 +destination.fanoutQueue2 = fanout://amq.fanout//message_queue2 +destination.fanoutQueue3 = fanout://amq.fanout//message_queue3 + +# for producer destination.fanoutQueue = fanout://amq.fanout//message_queue
\ No newline at end of file |
