14 Replies Latest reply on Feb 4, 2004 12:47 AM by prabodh

    schedule message delivery

    jeshmir Newbie

       

      "jeshmir" wrote:
      Is it possible to schedule a delvery time on the messages so that the recepient gets the message only at a certain time. Or is it possible to set a delay on the JMS message


        • 1. Re: schedule message delivery
          Adrian Brock Master

           

          "adrian@jboss.org" wrote:
          "adrian@jboss.org" wrote:
          "adrian@jboss.org" wrote:
          This was a recently added feature.
          http://sourceforge.net/tracker/index.php?func=detail&aid=744455&group_id=22866&atid=381174

          I think it is only in 3.2.2RC1

          Regards,
          Adrian


          • 2. Re: schedule message delivery
            Stephane Nicoll Master

             

            "Dark_Lord" wrote:
            Do you know when 3.2.2 will be released?


            • 3. Re: schedule message delivery
              sanjewad Newbie

               

              "sanjewad" wrote:
              Have you got an example of this using Scheduling with TOPIC or QUEUE.
              Can you please attach to this forum if you have worked out an scheduled delivery example.


              • 4. Re: schedule message delivery
                Elias Ross Master

                 

                "genman" wrote:

                Deliver a message in 1 minute:


                Message m;
                //...

                long at = System.currentTimeMillis() + 60 * 1000;
                m.setLongProperty(
                "JMS_JBOSS_SCHEDULED_DELIVERY", at);


                • 5. Re: schedule message delivery
                  GUSTAVO ALVAREZ Newbie

                   

                  "gustavo" wrote:
                  Hi,

                  I've tried that workaround with jboss-3.2.1_tomcat-4.1.24 distribution, but I get a javax.jms.JMSException: Bad property name

                  I tried to create a new message with
                  "JMS_JBOSS_SCHEDULED_DELIVERY" or
                  "JMS_JBOSS_REDELIVERY_DELAY", and also to modify the message received by the queue.

                  but none of them worked. Why could it be that way? My onMessage() is implemented by a MDBean, is that wrong?

                  Thank you.


                  • 6. Re: schedule message delivery
                    Elias Ross Master

                     

                    "genman" wrote:

                    Look up: The feature is for 3.2.2...


                    • 7. Re: schedule message delivery
                      GUSTAVO ALVAREZ Newbie

                       

                      "gustavo" wrote:
                      Sorry, you are right !


                      • 8. Re: schedule message delivery
                        dsambandan Newbie

                         

                        "dsambandan" wrote:
                        "adrian@jboss.org" wrote:
                        This was a recently added feature.
                        http://sourceforge.net/tracker/index.php?func=detail&aid=744455&group_id=22866&atid=381174

                        I think it is only in 3.2.2RC1

                        Regards,
                        Adrian



                        Adrian

                        Can we make this as a configurable property in service xml? ie. user can specify RedeliveryDelay and RedeliveryLimit parameters as an attribute to org.jboss.mq.server.jmx.Queue MBean for each Queue. BasicQueue.java can set the default value (configured in the service xml) for each message.



                        jms-service.xml
                        --------------
                        <server>
                        <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=jms/TestQueue">
                        <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
                        <attribute name="JNDIName"> jms/TestQueue </attribute>
                        <attribute name="RedeliveryDelay"> 30000 </attribute>
                        <attribute name="RedeliveryLimit"> 100 </attribute>
                        </mbean>
                        </server>

                        BasicQueue.java
                        ---------------
                        
                        
                         /**
                         * Restore a message to the queue
                         */
                         class RestoreMessageTask implements Runnable
                         {
                        
                         public void run()
                         {
                         if (log.isTraceEnabled())
                         log.trace("Restoring message: " + message);
                        
                         try
                         {
                         SpyMessage spyMessage = message.getMessage();
                        
                         // Set redelivered, vendor-specific flags
                         spyMessage.setJMSRedelivered(true);
                         if (spyMessage.propertyExists(SpyMessage.PROPERTY_REDELIVERY_DELAY))
                         {
                         log.trace("message has redelivery delay");
                         long delay = spyMessage.getLongProperty(SpyMessage.PROPERTY_REDELIVERY_DELAY);
                         message.messageScheduledDelivery = System.currentTimeMillis() + delay;
                         }
                        
                        //[Devaraj]--->
                        // If redelivery delay is not specified in the message header, then use the value specified
                        // in queue configuration.
                        
                         else if( parameters.redeliveryDelay > 0 )
                         {
                         message.messageScheduledDelivery = System.currentTimeMillis() + parameters.redeliveryDelay;
                         }
                        
                        
                        //If message doesnt have Redelivery Limit, then use the value specified
                        // in queue configuration.
                        
                         if (! spyMessage.propertyExists(SpyMessage.PROPERTY_REDELIVERY_LIMIT)
                         && parameters.redeliveryLimit >= -1 )
                         {
                         spyMessage.header.jmsProperties.put(SpyMessage.PROPERTY_REDELIVERY_LIMIT,
                         new Integer(parameters.redeliveryLimit));
                         }
                        
                        //<---[Devaraj]
                        
                        
                        BasicQueueParameters.java
                        ------------------------
                        public class BasicQueueParameters
                        {
                         /** The maximum depth of a queue */
                         public int maxDepth = 0;
                        
                        //[Devaraj]--->
                         /** The delay in milliseconds before the rolled back or recovered messages are redelivered **/
                         public long redeliveryDelay =-1 ;
                        
                         /** The number of times a message will be redelivered after a recover or rollback. **/
                         public int redeliveryLimit =-1 ;
                        
                        //<---[Devaraj]
                        }
                        
                        Queue.java
                        ---------
                        public class Queue
                         extends DestinationMBeanSupport
                         implements QueueMBean
                        {
                         JMSQueue destination;
                        
                        //[Devaraj]--->
                        
                         /**
                         * Get the redelivery limit.
                         *
                         */
                         public int getRedeliveryLimit( )
                         {
                         return parameters.redeliveryLimit;
                         }
                        
                         /**
                         * Set the redelivery limit.
                         *
                         */
                         public void setRedeliveryLimit(int limit )
                         {
                         parameters.redeliveryLimit = limit;
                         }
                        
                         /**
                         * Gets redelivery delay attribute of the BasicQueue object
                         */
                         public long getRedeliveryDelay( )
                         {
                         return parameters.redeliveryDelay;
                         }
                        
                        
                         /**
                         * Set redelivery delay attribute
                         */
                         public void setRedeliveryDelay(long rDelay )
                         {
                         //update it to basic queue parameters
                         parameters.redeliveryDelay = rDelay;
                         }
                        //<---[Devaraj]
                        ....


                        • 9. Re: schedule message delivery
                          Elias Ross Master

                           

                          "genman" wrote:
                          If you can create a proper patch file and mail it to me, I can apply the changes to the JMS source.

                          1. Check out anonymous CVS the jboss tree

                          $ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/jboss \
                          co -r Branch_3_2 jboss-3.2

                          2. Apply changes and test(!). Be sure you can change the settings via JMX and the queue configuration file. If you can create some test cases (in the 'tests" module) that would be helpful.
                          3. Create a diff of your changes in the "jbossmq" directory.

                          $ cvs diff -u > mq.patch

                          4. Email to me (eross at mqube dot net)


                          • 10. Re: schedule message delivery
                            dsambandan Newbie

                            Genman,
                            Could please send me your email id.

                            devaraj

                            • 11. Re: schedule message delivery
                              Elias Ross Master


                              I can't get the e-mail thing to work

                              It's

                              eross (at) m-qube . com

                              • 12. Re: schedule message delivery
                                Adrian Brock Master

                                We should extend the patch to include other properties like
                                persistent delivery or message time to live.

                                Regards,
                                Adrian

                                • 13. Re: schedule message delivery
                                  Elias Ross Master


                                  I checked it in. I'm not 100% pleased, however.

                                  I think we should be able to set default properties per queue. Something like:


                                  <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager

                                  VENDOR_PROP=abcde
                                  JBOSS_REDELIVER_DELAY=2000
                                  JMSExpiration=5005500
                                  ....



                                  They'd also be update-able via JMX.

                                  • 14. Re: schedule message delivery
                                    prabodh Newbie

                                    I am using JBoss 2.4.4 ver!!!
                                    I have an adapter which pings JMS for any new messages. Now when my adapter (which uses open source, open3.jar) is not started & a new message arrives, my adapter is unable to detect it & hence message is lost.
                                    Where the messages are stored in JBoss & how I can unregister them ?