2 Replies Latest reply: Feb 25, 2013 10:23 AM by joan_esteve RSS

    Best way to configure redelivery limit value for a Queue

    joan_esteve
      Hello,

      My doubt is related to configuring the JMS Redelivery Limit property from Weblogic 9.2 Server.

      We must support redelivery attempts in our queue, with a redelivery delay of 30s. So, we have set the queue's Redelivery Limit property to -1, via Console Configuration:

      Settings for My_DQueue -> Delivery Failure -> Redelivery Limit = -1

      The consumer of that queue is a MDBBean, which extends org.springframework.ejb.support.AbstractJmsMessageDrivenBean.

      The producers to that queue are weblogic.jms.extensions.WLMessageProducer.

      That queue has an error queue configured as Error Destination.

      Then, the WLMessageProducer is the one who specifies that value:
      WLMessageProducer messageProducer = (WLMessageProducer)queueSession.createProducer(queue);
      messageProducer.setRedeliveryLimit(5);
      However, we will not be able to ensure that all message producers pointing that queue will specifiy that redelivery limit. This may lead us to problems, as default queue Redelivery Limit is set to -1, and messages without specified redelivery limit would be redelivered indefinitely.

      I'd like to know if there is any way to specify a MAXIMUM redelivery limit value for a JMS queue. For example: fixing that limit to 10. If producers specify by themselves a redelivery limit lower than such value, that limit is applied to messages. Otherwise, the configured default limit value is used.

      Another option we have considered is to include, in the MDB's onMessage() method, a validation of the "JMS_BEA_RedeliveryLimit" message property:

      This validation would check whether no redelivery limit is configured in the Producer, and would forward such messages directly to the error queue, from the MDB, when the "JMSXDeliveryCount" outnumbers our fixed value:
      public void onMessage(Message message) {
         try {
            if(message.getIntProperty("JMS_BEA_RedeliveryLimit")<0){
               //MESSAGE FOUND WITHOUT REDELIVERY LIMIT SPECIFIED BY PRODUCER. 
               //POTENTIAL DANGER OF BEING REDELIVERED INDEFINETELY
               int deliveryCount = message.getIntProperty("JMSXDeliveryCount");
               if(deliveryCount>10){
                   //CAN I FORWARD MESSAGE TO ERROR DESTINATION?
      But we were not able to found such examples to achieve this

      Thanks in advance!

      Joan Esteve
        • 1. Re: Best way to configure redelivery limit value for a Queue
          Tom B
          Hi Joan,

          I just double-checked, and as far as I can tell the options for setting a redelivery limit include programmatically on the Producer or by configuring an override on the Destination. Unfortunately, you need the override to only take effect if the delivery limit hasn't already been set. (If we had a default deliverylimit configurable on our connection factory, this would have done the trick.)

          I think you've already hit upon the solution: your consumers can check each received message's JMSXDeliveryCount and act accordingly. It's fine for a consumer to use the JMS_BEA_RedeliveryLimit property see if the Limit has been set by a producer, and then check JMSXDeliveryCount to check the delivery count, but I'm not sure if the JMS_BEA_RedeliveryLimit property is set in older versions (8.1 may not have it for example).

          As a refinement, you may want to use the WLMessageProducer forward() API. This is an alternative to send() that preserves the message-id and timestamp of a consumed message. I don't think forward() allows any modification of the consumed message before it's forwarded.

          Hope this helps,

          Tom

          Edited by: Tom B on Feb 22, 2013 10:03 AM
          • 2. Re: Best way to configure redelivery limit value for a Queue
            joan_esteve
            Thank you Tom,

            I finally decided to specify an expirationTime for my messages, directly on the queue's XML configuration. If i need a MAX redelivery limit, i set my expirationTime as MAX_LIMIT x REDELIVERY_DELAY, and set a "Redirect" expiration policy.

            It's not the exact way to achieve that i would have desired, however it works.

            Thanks again

            Joan Esteve