-
1. Re: HornetQ and topics with DLA
ataylor Jan 3, 2012 7:20 AM (in response to yannalbou)any chance you could provide a unit test then i will take a look
-
2. Re: HornetQ and topics with DLA
yannalbou Jan 3, 2012 1:31 PM (in response to ataylor)I tried to create the test based on "org.hornetq.tests.integration.jms.server.management.JMSQueueControlTest"
But I am stuck because the TopicControl interface doesn't contain a get/setDeadLetterAddress and sendMessageToDeadLetterAddress methods as it exists for the JMSQueueControl interface.
so the following code cannot compile:
{code}
public void testSendMessageFromTopicToDeadLetterAddress() throws Exception
{
String deadLetterQueue = RandomUtil.randomString();
serverManager.createQueue(false, deadLetterQueue, null, true, deadLetterQueue);
HornetQQueue dlq = (HornetQQueue)HornetQJMSClient.createQueue(deadLetterQueue);
Connection conn = createConnection();
conn.setClientID("aClientID");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
String topicName = RandomUtil.randomString();
serverManager.createTopic(false, topicName, topicName);
HornetQTopic topic = (HornetQTopic)HornetQJMSClient.createTopic(topicName);
MessageProducer producer = sess.createProducer(topic);
// send 2 messages on queue
Message message = sess.createMessage();
producer.send(message);
producer.send(sess.createMessage());
conn.close();
TopicControl topicControl = ManagementControlHelper.createTopicControl(topic, mbeanServer);
JMSQueueControl dlqControl = ManagementControlHelper.createJMSQueueControl(dlq, mbeanServer);
Assert.assertEquals(2, topicControl.getMessageCount());
Assert.assertEquals(0, dlqControl.getMessageCount());
topicControl.setDeadLetterAddress(dlq.getAddress());
boolean movedToDeadLetterAddress = topicControl.sendMessageToDeadLetterAddress(message.getJMSMessageID());
Assert.assertTrue(movedToDeadLetterAddress);
Assert.assertEquals(1, topicControl.getMessageCount());
Assert.assertEquals(1, dlqControl.getMessageCount());
// check there is a single message to consume from queue
JMSUtil.consumeMessages(1, topic);
// check there is a single message to consume from deadletter queue
JMSUtil.consumeMessages(1, dlq);
serverManager.destroyQueue(deadLetterQueue);
}
{code}
I am using the last hornetQ release 2.2.5, maybe I should try on the trunk ?
Or should I do it another way ?
Thanks
Yann.
-
3. Re: HornetQ and topics with DLA
yannalbou Jan 6, 2012 5:00 PM (in response to yannalbou)Any idea?
Thanks
Yann
-
4. Re: HornetQ and topics with DLA
ataylor Jan 7, 2012 6:36 AM (in response to yannalbou)I will try to take a look next week. however, a proper test would be to set delivery attempts to 1 and the correct DLA, send 1 message, consume the message then roll back. do a receive immediate and assert null was returned and then consume from the DLA and assert not null.