The unit tests are always a great starting point for working code: have a peek at http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java?view=markup
I think below you need to sent to a topic called: VirtualTopic.orders On 12 June 2012 18:31, rwolson <[email protected]> wrote: > Good afternoon, > > I’m attempting to use ActiveMQ 5.6.0 VirtualTopics for the first time. > Also, I’m somewhat a newbie to ActiveMQ and JMS. > > I created a class based upon an shown in ActiveMQ in Action, page 285. > The code follows for reference: > public void sendAndConsumeVirtualTopic() throws JMSException { > String brokerURI = > ActiveMQConnectionFactory.DEFAULT_BROKER_URL; > > ConnectionFactory connectionFactory = new > ActiveMQConnectionFactory(brokerURI); > Connection consumerConnection = > connectionFactory.createConnection(); > consumerConnection.start(); > > Session consumerSessionA = > consumerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE); > Queue consumerAQueue = > consumerSessionA.createQueue("Consumer.A.VirtualTopic.orders"); > MessageConsumer consumerA = > consumerSessionA.createConsumer(consumerAQueue); > MessageListener listener = null; > consumerA.setMessageListener(listener); > > //setup the sender > Connection senderConnection = > connectionFactory.createConnection(); > senderConnection.start(); > Session senerSession = senderConnection.createSession(false, > Session.AUTO_ACKNOWLEDGE); > Topic ordersDestination = > senerSession.createTopic(ExamplePublishAndSubscribe.TOPIC1); > MessageProducer producer = > senerSession.createProducer(ordersDestination); > > String[] arry = {"Alpha", "Bravo", "Charlie", "Delta", "Echo", > "Foxtrot", > "Golf", "Hotel", "India", "Juliett", "Kilo", "Lima", "Mike", "November", > "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", > "Whiskey", "Xray", "Yankee", "Zulu"}; > int index = 0; > while(index < arry.length) { > TextMessage message = > senerSession.createTextMessage("Here is a message > [" + msgCount + "] " + arry[msgCount].toString() + " at: " + new Date()); > producer.send(message); > index++; > } > > consumerConnection.close(); > bStopped = true; > } // end method > > I’m successfully sending messages to Topics and the method creates a queue. > However, I don’t see any messages in the queue. Also, the code example > references a getMessageListener(), but since it’s not included within the > book’s source code, I suspect maybe I’m incorrectly initializing the > MessageListener. So, how do I setup the MessageListener? > > I included the following entries within the activemq.xml and know they’re > read because I initially generated an error. > <destinationInterceptors> > <virtualDestinationInterceptor> > <virtualDestinations> > > > <virtualTopic name="orders" > > prefix="VirtualTopic.*." /> > </virtualDestinations> > </virtualDestinationInterceptor> > </destinationInterceptors> > > Do I need to define the queue within the destinationInterceptors? > > So, the questions just in case they’re hard to find: > - *how do I setup the MessageListener?* > - *Do I need to define the queue within the destinationInterceptors?* > > Thanks, > Rich > > > -- > View this message in context: > http://activemq.2283324.n4.nabble.com/Questions-re-VirtualTopics-tp4653208.html > Sent from the ActiveMQ - Dev mailing list archive at Nabble.com. -- http://fusesource.com http://blog.garytully.com
