Interesting topic. I started a blog, which is not complete, but has most of the concepts for what you are looking for: http://www.baselogic.com/blog/java/testing-activemq-virtualtopics-using-camel-and-junit
I have been working with the Camel and AMQ team on this, and I am close to have a fully tested solution.... I have a FAT Client that has a Spring MDP, that I want to dynamically switch the QUEUE destination at runtime. Here is the unit test for the changing of destinations: @Test @DirtiesContext public void testChangeMessageDestination() throws Exception { log.info("Send a test message to Table Service"); log.info("***** testChangeMessageDestination() ********************************"); DefaultMessageListenerContainer container = (DefaultMessageListenerContainer)context.getBean("jmsListener12"); assertNotNull(container); assertTrue(container instanceof DefaultMessageListenerContainer); assertEquals("Consumer.12.VirtualTopic.Table.12", container.getDestinationName()); resultChangeMessageDestination.expectedMessageCount(0); // Send the test message to make Server Service create our Status Message // Message to be sent to 'VirtualTopic.Table.1' , NOT 'VirtualTopic.Table.12' producerTemplate.sendBody("jms:queue:sendStatusUpdate", ExchangePattern.InOnly, 1); // now lets assert that the mock endpoint received messages resultChangeMessageDestination.assertIsSatisfied(); resultChangeMessageDestination.reset(); log.info("* valid message received.---------------------------------"); ActiveMQQueue newDestination = new ActiveMQQueue("Consumer.12.VirtualTopic.Table.1"); container.setDestination(newDestination); * resultChangeMessageDestination.expectedMinimumMessageCount(4);* // Send the test message to make Server Service create our Status Message // Message to be sent to 'VirtualTopic.Table.1' , NOT 'VirtualTopic.Table.12' producerTemplate.sendBody("jms:queue:sendStatusUpdate", ExchangePattern.InOnly, 1); // now lets assert that the mock endpoint received messages resultChangeMessageDestination.assertIsSatisfied(); resultChangeMessageDestination.reset(); log.info("* no message received again.---------------------------------"); newDestination = new ActiveMQQueue("Consumer.12.VirtualTopic.Table.BAD"); container.setDestination(newDestination); resultChangeMessageDestination.expectedMinimumMessageCount(0); // Send the test message to make Server Service create our Status Message producerTemplate.sendBody("jms:queue:sendStatusUpdate", ExchangePattern.InOnly, 1); // now lets assert that the mock endpoint received messages resultChangeMessageDestination.assertIsSatisfied(); } - One of the biggest issues I can seem to understand, is why I get 4+ messages onto the queue from my VirtualTopic. - I also have some doubts on either the way I am using the the Mocks, or the Mocks themselves as if I change the expected number of messages received, I stop getting any messages to those Mocks. - I also, can not seem to validate the changed name in the * container.getDestinationName()* call after I change the destination. --- Thank You… Mick Knutson, President BASE Logic, Inc. Enterprise Architecture, Design, Mentoring & Agile Consulting p. (866) BLiNC-411: (254-6241-1) f. (415) 685-4233 Website: http://baselogic.com Linked IN: http://linkedin.com/in/mickknutson Vacation Rental: http://tahoe.baselogic.com --- On Mon, Sep 7, 2009 at 1:28 AM, niko_dim <nikk....@gmail.com> wrote: > > Hi, > > I want to dynamically create destinations after startup of my embedded > broker. I saw several examples how create ServiceBroker with configuration > file but all configurations were done before start of the broker. > Unfortunately this does not fit to the requirements of my project. I do not > want to restart the broker or use createTopic() & createQueue() methods of > the session. > The broker that I am using is embedded and use of specific methods is not > an > issue. > > Thanks for the help. > Nikodim > -- > View this message in context: > http://www.nabble.com/How-to-create-destinations-after-the-start-of-embedded-broker-tp25326803p25326803.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. > >