2

I have a saga which represents a long-running work assignment process of a "Person" to a "Case". Several events may kick it off, and at the end of the process we have an assignment confirmation, at which point the saga completes and the Person is assigned to the Case. I would like to have a timeout for this saga so that we don't wait indefinitely for confirmation - definitely a valid business use case. No difficulties there - fairly vanilla.

The twist is that this assignment process can be blocked if someone puts the Case on hold. I have an event I can subscribe to so my assignment saga knows the Case is on hold, but unless I adjust the timeout or suspend it in some way, the assignment saga will likely time out before the Case hold is released. It doesn't make business sense to do this, so I basically want to stop the timeout clock until some other event comes in.

This same issue was mentioned here a couple years ago. Is this still not possible or are there new features in v3.x that would allow it? If not, is it a planned feature?

Thanks!

Community
  • 1
  • 1
killthrush
  • 4,859
  • 3
  • 35
  • 38

2 Answers2

3

Why not remove the timeout altogether for the instance when your case is put on hold? Your saga maintains the state of the case and the calculated time when the case would have been due. This could have been set when you created the first timeout. When the case is reactivated, simply calculate the difference in time from the reactivation and the saved "deadline", and create a new timeout for that instance with the difference. You may also want to take into account the time the case was on hold and set a new deadline which you would save back to the instance state.

stephenl
  • 3,119
  • 4
  • 22
  • 22
  • Just wanted to give you some credit for this - I definitely think I will need to be a bit more intelligent about what my timeout value needs to be when my case comes off hold. I hadn't considered that - thanks! – killthrush Feb 07 '13 at 18:00
2

I don't think there is a way to tab directly to the timer and put the timeout message "on-hold"

I would have that logic inside the timeout handler on the saga. Check if the case is on hold and request another timeout without ending the saga.

Sarmaad
  • 426
  • 3
  • 7
  • You will always need to deal with the race condition of the "on-hold" command coming just as the timeout is occurring, in which case, you couldn't actually code the scenario any differently even if you could suspend or modify the timeout. – Udi Dahan Feb 07 '13 at 03:25
  • That's true.. hence why you need to know the business cost/resolution if the case was "timed-out" just before the case was put on "hold" – Sarmaad Feb 07 '13 at 07:35
  • Thanks guys! I think this pattern will work fine for me and for others, so I consider it the "answer". Depending on the details of the domain however, I will probably also need to consider what @stephenl posted as well. We may not want to reset the clock to "zero" but reset it to some other value derived from the saga data. – killthrush Feb 07 '13 at 17:59