Design question - How to extend current deadline once the deadline deadlinehandler is invoked


Our project is related to vehicle logistics and distribution of vehicle into network.
So, we basically collect events of a vehicle journey that are produced in plant and ready to be picked up by logistics parties to deliver to the dealer)
and this happens with multiple stops and multiple carriers.

Now, let’s say that, in a vehicle journey from point A to point B, we know that we have N amount of events that should happen.
After, we are posting commands to our aggregate to write planned events and have a saga to schedule a deadline for each actual event expected.
When a third party logistic provider actually moves the vehicle and sends the events then, we cancel the deadline.

Given this scenario, I have a couple of questions on deadline manager usage and event naming convention.

  1. Does it makes sense to write a planned event that is yet to happen on so and so date into Eventstore? – VehicleGateReleasePlannedEvent
  2. Now, lets say, there is a event called VehicleGateReleasePlannedEvent and we have a deadline in a minute for the actual event called GateReleasedEvent .
    If this event doesn’t happen then how can I make my deadlinehandler to extend the current deadline?

Here is my current approach:

a) Have the saga deadline handler send a command to aggregate and dump an event to the Eventstore called GateReleaseDelayed.
b) Again, have saga handler to react to the GateReleaseDelayedEvent and create one more deadline with the same the same pay load as the first one,
so the same deadline handler will be invoked and the cycle repeats until actual event happens.
c) On actual event happening cancel All deadlines by deadline name.

FYI - We are using axon server and framework version 4.1.2 with spring boot and in memory H2 DB configuration. Most of our code base is pretty default configuration.

Hi Aditya,

From the body of your message I cannot directly pull a question to be honest, so I am assuming the title is the question you actually have.
If you want to “reschedule” a deadline after a deadline message has been handled, I think the most straightforward solution is to reschedule it in that exact deadline handler (after you’ve likely set some state notifying the saga “will wait again” for a given event).

When it comes to canceling a deadline, you should use the DeadlineManager#cancelSchedule(String, String) method after you are ensured the event has been handled by the Saga.
For the cancel operation, you are required to give the deadline name (which you provided when you scheduled the deadline) and the scheduleId (which was returned to you after scheduling said deadline).

Hope this points you in the right direction Aditya, and please do not hesitate to ask further questions if my response isn’t clear enough!