Hi
I’m looking for the best pattern to handle service tasks that may run for a long time. I know that when we’re using a worker (like the createWorker function or one level higher the job streaming), under the hood, the SDK activates and locks that job for that particular worker so the worker can complete or fail it if required.
what if the service task requires a long period to complete? we can’t just leave the worker hanging until it is complete
for example we might call API to another service that does some sort of heavy computation that may take an hour, or we come across a situation where a service tasks requires a day to complete.
I’m not sure extending the timeout would be an appropriate solution, please correct me if I’m wrong.
this whole situation here is somehow ambiguous for me so any advice would be highly appreciated.
thank you in advance.
zbGrpcClient.streamJobs({
type: "the type defined in the modeler",
worker: "some string",
tenantIds: [],
pollMaxJobsToActivate: 5, //should be a number
timeout: 30_000, // **this is related to the question**
taskHandler: async (job) {
// business logic code
// there may be API calls to other services here
return job.complete(); //this must be called and be returned
}
});