Chapter 6. Background Jobs
Once you have some third-party integrations, it’s likely that you’ll end up needing automated ways to keep the company’s data in sync with the third party’s data and to trigger other events like sending emails. That’s where background jobs and cron jobs come in.
A background job executes code or actions that need to run outside the flow of an API in a systematic way. This will include tasks like sending emails or doing complex calculations after a user has made an update. Background jobs are going to work alongside your server-side application code and are typically triggered directly from an endpoint call. These jobs are usually defined at the service level because they typically have business logic around them.
A cron job is a task that is executed on a schedule. It will run at some time interval you set based on the business needs. Syncing data from or to a third-party service on a schedule is a prime example of using a cron job. Cron jobs can be in your ...
Get Full Stack JavaScript Strategies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.