4 Replies Latest reply on Jan 15, 2003 11:18 AM by schrouf

    Message Delay and redelivery count in jbossmq

    kkeyan_b

      Hi,
      We are using an mdb which listens to a queue and posts the message to a servlet for processing.The servlet to which we are posting might become temporarily unavilable due to network or some other problems.So during that time if any message comes if i use container managed MDB the transaction gets rolled back and the message gets redelivered again and again until jboss uses all the available memory in the system.So to avoid this problem i want to set the number of times a message is redelivered or when an exception occurs delay the message so that the redelivery occurs after some time.How can i do this in jbossmq.JMS api does not seems to have any specific setting even though most app server vendors like oracle,weblogic have extended their jms implementation to have the facility of setting the redelivery count or setting a message delay.Any help on how this can be done in jboss would be greatly appreciated.
      regards
      karthik

        • 1. Re: Message Delay and redelivery count in jbossmq

          I don't think there is a delay parameter
          (I could be wrong), but you can configure
          a Dead Letter Queue where messages go
          when they are redelivered too many times.

          Look in docs/dtd/jboss_3_0.dtd
          for container-invoker-conf and MDBConfig/DLQConfig

          Regards,
          Adrian

          • 2. Re: Message Delay and redelivery count in jbossmq
            schrouf

            I have developed a simple delay interceptor for the message driven bean container configuration ( have a look at configuration "Standard Message Driven Bean" in standardjboss.xml in the JBoss conf-directory, ).

            On interceptor chain invocation for the onMessage()call it simply checks if the message is marked as redelivered ( Message.getJMSRedelivered() ).

            If so, than it simply puts the executing thread to sleep for a certain time periode, effectivly delaying the message redelivery . As the executing thread belongs to the MDB-specific message driven bean container thread pool, this blocking has no negativ impact on the overall application server processing.

            • 3. Re: Message Delay and redelivery count in jbossmq
              paulbandler

              I need to do pretty much the same - any chance of you posting your delay interceptor code (either here or directly to me at pbandler@nexagent.com) as there is precious little documentation available on writing ones own interceptor.

              In particular from browsing the interceptor source the code path to get from a 'receive(...)' entry point to getting hold of an actual message reference looks rather tortuous so it would be really helpful to me to see your code. I'm wondering whether I'm actually looking at the right interceptors as I've been looking at generic JMS interceptors that are nothing to do with MDB's.

              Thanks in advance.

              Paul Bandler

              • 4. Re: Message Delay and redelivery count in jbossmq
                schrouf

                Here is the source for my simple JMS redelivery delay interceptor as an eclipse project. Build the jar file, deploy it to <your-jboss-config>/lib and modify the 'Standard Message Driven Bean' container configuration in <your-jboss-config>/conf/ standardjboss.xml to include the new interceptor into the interceptor chain for the standard jboss MDB container.

                ....
                <container-configuration>
                <container-name>Standard Message Driven Bean</container-name>
                <call-logging>false</call-logging>
                <container-invoker>org.jboss.ejb.plugins.jms.JMSContainerInvoker</container-invoker>
                <container-interceptors>
                org.jboss.ejb.plugins.LogInterceptor
                de.mobilcom.eai.adapter.base.RedeliveryDelayInterceptor
                org.jboss.ejb.plugins.RunAsSecurityInterceptor
                <!-- CMT -->
                ...