-
1. Re: Are Virtual Consumers Durable?
gseben May 18, 2009 1:23 PM (in response to gmotts_gary.motts)Hi Gary,
In the case of Virtual Topics the consumers are not durable subscribers. When a consumer is created for a Virtual Topic, it has to consume messages from a queue that is associated with that virtual destination. For example, in your case Consumer.example.VirtualTopic.topic, should be the queue from where your consumers will receive messages sent to VirtualTopic.topic. Message durability is then guaranteed by the queue.
This snippet of code from one of the Junit tests in the source might help you see how it all fits together:
public void testVirtualTopicCreation() throws Exception { if (connection == null) { connection = createConnection(); } connection.start(); ConsumerBean messageList = new ConsumerBean(); messageList.setVerbose(true); String queueAName = getVirtualTopicConsumerName(); // create consumer 'cluster' ActiveMQQueue queue1 = new ActiveMQQueue(queueAName); ActiveMQQueue queue2 = new ActiveMQQueue(queueAName); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer c1 = session.createConsumer(queue1); MessageConsumer c2 = session.createConsumer(queue2); c1.setMessageListener(messageList); c2.setMessageListener(messageList); // create topic producer MessageProducer producer = session.createProducer(new ActiveMQTopic(getVirtualTopicName())); assertNotNull(producer); int total = 10; for (int i = 0; i < total; i++) { producer.send(session.createTextMessage("message: " + i)); } messageList.assertMessagesArrived(total); } protected String getVirtualTopicName() { return "VirtualTopic.TEST"; } protected String getVirtualTopicConsumerName() { return "Consumer.A.VirtualTopic.TEST"; }
-Giovani
-
2. Re: Are Virtual Consumers Durable?
gmotts_gary.motts May 19, 2009 9:35 AM (in response to gseben)So if I understand correctly, message delivery between the virtual topic and the virtual consumer is "guarenteed", i.e. "durable" when the consumer is made available and the queue session is establilshed to the topic. When a message is published to the Virtual Topic and the consumer is "offline", it will retain the message until the consumer connection is re-established.
-
3. Re: Are Virtual Consumers Durable?
mickknutson_mickknutson Aug 3, 2009 8:17 PM (in response to gseben)Can you help me to understand how to use Camel and an embedded AMQ to test this?