You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In the new worker implementation, there is no way to subscribe to job result.
Expected behavior
A feature that would allow us to subscribe to job process and its full resulting value, or at least some identifier (e.g. filepath).
Environment (please complete the following information):
@vendure/core version: v1.0.beta3
Additional context
We use worker for heavy tasks even in normal request/response cycle. For example user requests new PDF invoice, task is handled over to worker and then we want to send the PDF file to the user when it's ready.
The text was updated successfully, but these errors were encountered:
Outlining the problem to solve: with the old microservices architecture, it was straightforward because the code that created the job (jobQueue.add()) was running in the same process that also dispatched the work to the worker, and the NestJS microservice allowed us to send messages back to the server.
Now we have a pure job queue, there is no built-in communication channel from worker -> server.
So the basic mechanism of being able to get the results of a worker job would go like this:
Create a job with jobQueue.add(). In the DefaultJobQueuePlugin we'd get a Job object back which had an ID of the row in the DB.
To subscribe to the results of that job, we'd then need to poll the DB for changes to that job. Since we have the ID, this is a very simple and light query. When polling, we inspect the Job state, result and error properties and when we find changes we can register that the Job updated (completed or failed).
We don't want to trigger polling for all jobs. Only when needed. So we need some way to lazily trigger polling only when the code actually requires the result of the job. Using an observable would work well here since they are lazily evaluated (will only execute if subscribed to).
Other JobQueueStrategies (e.g. Google Pub/Sub) don't have any means of transmitting data back to the caller, so we'd need to have this capability dependent on the strategy (e.g. throw an error when someone attempts to subscribe to the result of a Job where the strategy does not support it).
Describe the bug
In the new worker implementation, there is no way to subscribe to job result.
Expected behavior
A feature that would allow us to subscribe to job process and its full resulting value, or at least some identifier (e.g. filepath).
Environment (please complete the following information):
Additional context
We use worker for heavy tasks even in normal request/response cycle. For example user requests new PDF invoice, task is handled over to worker and then we want to send the PDF file to the user when it's ready.
The text was updated successfully, but these errors were encountered: