Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-3669

When Using a Specific Date Release, DelayHandler.reschedulePersistentMessage() Releases Messages Too Soon



    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.0.5, 4.1 GA, 4.0.6, 4.1.2
    • Fix Version/s: 3.0.7, 4.2 M1, 4.0.7, 4.1.3
    • Component/s: Core
    • Labels:


      DelayHandler with MessageStore releases messages too soon.

      Consider a messages which get persisted in a delayer's message store with an expression equal to a Date (indicating the time when it should be released).

      Then the system is shutdown for maintenance, and turned back on e.g. 2 hours later.
      On startup of the system, on ApplicationContextRefreshed DelayHandler.reschedulePersistentMessages is called. It will iterate over the persisted messages, determine the delay when they should be released and schedule this release.
      However, in determining the delay, the current Date is compared to the expressions Date object, and in the scheduling, the schedule Date is created by adding the difference to the Request Date instead of the Current Date.
      As a result, message are released too soon.

      Concrete example.

      <int:delayer id="requestDelayer" default-delay="600000" message-store="delayMessageStore"
      expression="headers[T(myclass.MessageHeaderConstants).DELAY] >

      Message in store with Request date 10am and "Delay" header 2pm. Current time 10am. System is shutdown.
      At 1pm the system is brought back up.
      The determineDelayForMessage will calculate a delay equal to 1 hour in milliseconds (2pm - 1pm). Then releaseMessageAfterDelay will schedule the message for release at 11am (10am + 1h), which will fire right away because it already passed. If the system wasn't restarted, the message would stay in the store until 2pm.

      Can be fixed by either calculating delay relative to request time or by scheduling relative from current time instead of request time DelayHandler




            abilan Artem Bilan
            jeroenost Jeroen Ost
            0 Vote for this issue
            2 Start watching this issue