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

    HornetQ and topics with DLA

    yannalbou

      Hi,

       

       

      I have a question regarding topics with HornetQ.

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

       

       

      {code:xml}

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

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

           </topic>

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

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

           </topic>

      {code}

       

       

      {code:xml}

           <address-settings>

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

                     <dead-letter-address>jms.topic.com.myCompany.TopicError</dead-letter-address>

                </address-setting>

           </address-settings>

      {code}

       

       

      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 ?

       

       

      Thanks

      Yann.

        • 1. Re: HornetQ and topics with DLA
          ataylor

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

          • 2. Re: HornetQ and topics with DLA
            yannalbou

            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

              Any idea?

              Thanks

               

              Yann

              • 4. Re: HornetQ and topics with DLA
                ataylor

                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.