Support for Time based event - for polling the external system

I have a requirement wherein based on a Event I trigger an external service that could run for hours, days even weeks Asynchronously.

I wanted to have a persistent way of poll the external service for status (of completion). Just wondering whether there is a way to trigger time based event and if it is are there any example/sample that helps.

I am not sure Saga is the right way to address this usecases.

eg:

  1. call External Service to initiate a long process…
  2. poll every 5 mins to check whether process is complete
  3. Once the process completes, update the status and mark the process as done.

Appreciate any pointers.

TIA

Hello,

I’m guessing that you could use something from the deadline handler? https://groups.google.com/forum/#!topic/axonframework/mSpw9AJaDfE
I’m also unsure as you about the saga use case here, the other approach would be to handle the ‘deadline’ by spring’s job or some other looping service in the background that would send status update command

W dniu czwartek, 23 maja 2019 20:52:49 UTC+2 użytkownik Arunkumar Jayaraman napisał:

Thanks Robert! Will try the deadlinemanager - looking at the document it appears that it is the perfect one instead of polling based on the estimated time upfront. Will let you know. For it to survive restarts, do I have to use quartz+deadlinemgr or will this persist its state and revive itself without quartz/ext-scheduler?

The problem with the looping service would be two fold

I would locking a thread until it is finished.

They may not survive restarts and needs custom logic to persist and restart on its own.

(currently I am doing the second - and to overcome second - providing custom interface to re-trigger failed ones - will try the deadlinemanager)
~JAK

Axon uses the spring’s quartz scheduler so to persist you need to configure the job store in spring, and once you do it you all jobs related with the axonframework should be persisted there.
I never used that, but i think it should work just fine.

(Here’s some info on how to configure the scheduler, job store etc)
https://www.baeldung.com/spring-quartz-schedule

W dniu poniedziałek, 27 maja 2019 09:08:32 UTC+2 użytkownik Arunkumar Jayaraman napisał:

We have restrictions on how often we can poll the external service - and potentially many items to poll.

So, we ended up delegating polling to a service which uses Spring’s @Scheduled feature.
The command handler that starts the external service creates an entry in a table of jobs to poll.
The polling service periodically queries for open jobs and can batch or defer as needed.
This job table also provides a history of all the interactions with the external service.

The polling service publishes events so we can continue to use Sagas with deadlines at the higher level of individual “jobs”.

hth