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 | fe8dfe8a8cf37457b758a8d86c8d947fd429aa83 (patch) | |
| tree | 5cc6860cc50081467d8cec733cb40251e857f509 /java/client/example/src | |
| parent | df0246fbcc92f9d7869f5ee00ed9335ce1c7fb4b (diff) | |
| download | qpid-python-fe8dfe8a8cf37457b758a8d86c8d947fd429aa83.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/qpid@639090 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/example/src')
3 files changed, 24 insertions, 11 deletions
diff --git a/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java b/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java index e813c0ce60..daa1b10b6b 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java +++ b/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/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java b/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java index 4d645888a3..fb750693b2 100755 --- a/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java +++ b/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/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties b/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties index bde9ae4dae..0f1dd43aa9 100644 --- a/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties +++ b/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 |
