How Tasks Work
An overview of Mergent Tasks
In Mergent, each unit of background work is represented by a task. Tasks are created by your application using Mergent’s client libraries (like mergent-js) or the API.
When a task gets created on Mergent, it is added to a queue, which reliably
persists tasks until they are ready to be processed by your application. You can
set tasks to process immediately, after a delay
, or at a specific
scheduled_for
time.
When a task is ready to be processed, Mergent sends a task request to your application via an HTTP POST request. Each individual task request is automatically logged and stored as an invocation.
Tip: Your application should keep Mergent’s HTTP request open while performing the task so that Mergent can keep track of the result.
Respond with a 200 OK
status code if the task was successful, or a 500 Internal Server Error
status code if the task failed.
In the case where a task fails or the task cannot be processed for any other reason (e.g., if your server is down), Mergent will attempt to retry the task request according to our retry policy.
Example: Let’s say you have an e-commerce platform and a customer makes a purchase. Sending a confirmation email is important but it isn’t time-sensitive and can be processed outside of the main flow, preventing slowdowns for other users.
In this scenario, you would create a task in Mergent that holds the information about the email and when it’s ready to be processed, Mergent sends a request to your application to send the email.
Was this page helpful?