Delaying Messages
Last updated
Was this helpful?
Last updated
Was this helpful?
In case of Ecotone we don't delay whole Message, but specific Message Handler. This helps in scenarios when we have multiple Event Handler and we would like to configure the delay differently. For example may we have a case, where as a result of Order being placed, we would want to delay notification, yet to call Payment Service right away.
You may delay handling given asynchronous message by adding #[Delayed]
attribute.
To dynamically calculate expected delay, we can use expression language.
payload variable in expression language will hold Command/Event object. headers variable will hold all related Mesage Headers.
We could also access any object from our Dependency Container, in order to calculate the delay and pass there our Command:
We may send an Message and tell Ecotone to delay it using deliveryDelay Message Header:
If Message Delay would be send for Event. Then all subscribing Event Handlers would be delayed. For customizing it on the single Handler level, use Message Handler delay.
We may also delay to given date time: