4 Replies Latest reply on Jan 7, 2012 6:36 AM by Andy Taylor

    HornetQ and topics with DLA

    Yann Albou Newbie




      I have a question regarding topics with HornetQ.

      I configured HornetQ with JMS durable subscription and with a DLA:




           <topic name="com.myCompany.Topic">

                <entry name="com/myCompany/Topic"/>


           <topic name="com.myCompany.TopicError">

                <entry name="com/myCompany/TopicError"/>







                <address-setting match="jms.topic.com.myCompany.Topic">







      The mbean : org.hornetq:module=Core,type=Queue,address="jms.topic.com.myCompany.Topic",name="jms.topic.com.myCompany.Topic" doesn't seem to be correctly configured: the DeadLetterAddress associated is "jms.queue.DLQ" and not "jms.topic.com.myCompany.TopicError"


      And then when a message goes in the DLA  it uses "jms.queue.DLQ"


      Did I miss something ?





        • 1. Re: HornetQ and topics with DLA
          Andy Taylor Master

          any chance you could provide a unit test then i will take a look

          • 2. Re: HornetQ and topics with DLA
            Yann Albou Newbie

            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:



               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();



                  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();






                  TopicControl topicControl = ManagementControlHelper.createTopicControl(topic, mbeanServer);

                  JMSQueueControl dlqControl = ManagementControlHelper.createJMSQueueControl(dlq, mbeanServer);


                  Assert.assertEquals(2, topicControl.getMessageCount());

                  Assert.assertEquals(0, dlqControl.getMessageCount());




                  boolean movedToDeadLetterAddress = topicControl.sendMessageToDeadLetterAddress(message.getJMSMessageID());


                  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);






            I am using the last hornetQ release 2.2.5, maybe I should try on the trunk ?

            Or should I do it another way ?




            • 3. Re: HornetQ and topics with DLA
              Yann Albou Newbie

              Any idea?




              • 4. Re: HornetQ and topics with DLA
                Andy Taylor Master

                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.