9 Replies Latest reply on Oct 2, 2008 1:17 PM by Clebert Suconic

    Message Scheduling

    Andy Taylor Master

      This is how i propose we handle message scheduling.

      Firstly the send method in ClientProducer will be overridden with a new parameter (long) to allow the scheduled time of message delivery to be specified. A new packet will be created, say SessionScheduledSendMessage, which will extend SessionSendMessage and have a scheduled time attribute.

      In ServerSession when we send the message if the scheduled delivery time is set and it is not involved in a tx we route the message and then update the references with the scheduled delivery time. If the message is persisted we then add a ''SET_SCHEDULED_DELIVERY_TIME' record. This is so on reload we can reschedule the messages. We then add to the queue as a scheduled message and the current queue code will take care of delivering when ready. If the message is part of a tx,we add it to the transaction marked as a scheduled message and on commit the messages will be handled the same way.

      One slight problem is how do we deal with this during page since when the message is depaged we won't know it was to be scheduled. Tim suggested adding and removing a property on page/depage, We could do this simply by adding a property to PageMessage and change the page method to have an additional oprtional property, Clebert any thoughts?

      Lastly on a JMS layer, it would work as in 1.4, I.e. you set a property on the message and we decide on send how to send it.

      comments!

        • 1. Re: Message Scheduling
          Clebert Suconic Master

           

          "ataylor" wrote:
          A new packet will be created, say SessionScheduledSendMessage


          Can't we use just a Header Property on the message for that?

          on your clientProducer method:

          ....
          message.setLongProperty("JBM-SCHEDULED-TIME", scheduledTime);
          ...



          I wouldn't put this on PageMessage, as the StorageManager will have the same problem. Say... If you restart the server with a message scheduled to be delivered at 8:00 AM next morning, you need to reload that from the journal/database also.

          I would or add a Property on the Message in such way it would be part of the encoding. Or a message Property, or a field being part of the encoding.

          • 2. Re: Message Scheduling
            Andy Taylor Master

             

            "clebert.suconic@jboss.com" wrote:
            "ataylor" wrote:
            A new packet will be created, say SessionScheduledSendMessage


            Can't we use just a Header Property on the message for that?

            on your clientProducer method:

            ....
            message.setLongProperty("JBM-SCHEDULED-TIME", scheduledTime);
            ...



            Well we have a different send method completely so putting it on the message at send is redundant.

            I wouldn't put this on PageMessage, as the StorageManager will have the same problem. Say... If you restart the server with a message scheduled to be delivered at 8:00 AM next morning, you need to reload that from the journal/database also.


            We add a record to the journal separately that marks a message as scheduled.

            I would or add a Property on the Message in such way it would be part of the encoding. Or a message Property, or a field being part of the encoding.


            We could do this, I don't think it makes much difference, we just have to make sure that the delivery time is saved.

            • 3. Re: Message Scheduling
              Tim Fox Master

              if a message is paged at its scheduled delivery time, then it's not in memory so it's clearly going to be late.

              In other words don't worry about it

              • 4. Re: Message Scheduling
                Clebert Suconic Master

                 

                "timfox" wrote:
                if a message is paged at its scheduled delivery time, then it's not in memory so it's clearly going to be late.


                You could set scheduled delivery time for a few hours from now, right?
                On that case you still need to save the delivery time on paging.

                • 5. Re: Message Scheduling
                  Tim Fox Master

                  What I meant was, if a message is paged at its scheduled delivery time then of course its not going to get delivered then, since it's paged.

                  • 6. Re: Message Scheduling
                    Andy Taylor Master

                     

                    You could set scheduled delivery time for a few hours from now, right?
                    On that case you still need to save the delivery time on paging.


                    yes, We still need to save the delivery time. The question is how. we can set a property on the message itself,removing it on depage, or just add it in the encode/decode of PageMessage.

                    Whether or not its delivered on time is moot.

                    • 7. Re: Message Scheduling
                      Clebert Suconic Master

                      If you could avoid a different Packet it would be better, as we would need also to deal with that also later on LargeMessage

                      IMO If you put the scheduledTime somehow on MessageImpl or ClientMessageImpl anyway you want, it would solve the problem on Paging + Remoting + Journal with a single shot.

                      • 8. Re: Message Scheduling
                        Tim Fox Master

                        Scheduled time is store on the reference level, not the message level, so it needs to be a separate update record in the journal.

                        • 9. Re: Message Scheduling
                          Clebert Suconic Master

                           

                          "timfox" wrote:
                          Scheduled time is store on the reference level, not the message level, so it needs to be a separate update record in the journal.



                          Hmm... Ok..
                          then Andy was right about adding the field on PageMessage. It should be a simple change.