You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2008/03/20 01:03:48 UTC
svn commit: r639090 - in
/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout:
Consumer.java Listener.java fanout.properties
Author: rajith
Date: Wed Mar 19 17:03:48 2008
New Revision: 639090
URL: http://svn.apache.org/viewvc?rev=639090&view=rev
Log:
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.
Modified:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties
Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java?rev=639090&r1=639089&r2=639090&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java (original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Consumer.java Wed Mar 19 17:03:48 2008
@@ -59,16 +59,20 @@
*
* @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 @@
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");
Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java?rev=639090&r1=639089&r2=639090&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java (original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/Listener.java Wed Mar 19 17:03:48 2008
@@ -39,17 +39,17 @@
/**
* 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 @@
*
* @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 @@
//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");
Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties?rev=639090&r1=639089&r2=639090&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties (original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/fanout/fanout.properties Wed Mar 19 17:03:48 2008
@@ -25,4 +25,9 @@
# 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