Hi,
I have a requirement , where my job consumer would start a Sling job, I have to wait till that finishes so that the necessary files are present in the correct state (This is a prewritten job) . then the consumer can move forward with it other functions.
How can I do so? What will be the correct way to approach this?
The correct flow is rather
we get an api call, we move that api call to a consumer, wait for the sling job to create the files, then process the initial api call.
Views
Replies
Total Likes
Hi Tasunil,
Expose API's to communicate clearly the status of the process.
So that in case of a long running job you would be able to come back and check for status every few seconds..
This way you avoid long wait and have short nice calls into your core Job/Service connected to it.
Regards,
Peter
Hello @Peter_Puzanovs ,
So that means we should have a poller which keeps checking the status?
Regards
Tarini
Hi Tarini,
Yes, that's one way to solve it,
Just keep the Service that know's it's state just a boolean, which is updated by the Job, so that it's near instant to know the state.
Regards,
Peter
Hi @tasunil1
How long the wait would be? The scheduled job will be executing immediately or it needs to wait.
The approach you can go with using threading, there you can pause the execution until the scheduled job is not executed, the job status you can get from /var/eventing/scheduled-jobs
Hello @arunpatidar
It is not a scheduled job.
The use case is some thing like
I have to create the current snapshot of the files based on a label. Since the labels can move so I cannot precalculate it.
THen once the snapshot is ready multiple types of operations can be performed on them like download the snapshot, export in a different format based on a label.
So the job which creates the snapshot is a sling job.
I would get an api call to download the snapshot. I would say the snapshot is being prepared and will get downloaded. In this the api params for download need to be save. Then wait for the snapshot to be created and using the initial params download the snapshot.
THis is what is a example
Regards
Tarini
ok, then I think you need to create a polling mechanism here to pause/resume/stop execution based on your requirement.
Have you already checked if an OSGI event will be sent when that job has completed? You can check in the OSGI webconsole ("OSGI" -> "Events").
currently that's the case, yes.
Views
Likes
Replies