Types of asynchronous messages
Asynchronous processing often comes in two different forms, such as push and pull. The strategy that you implement is dependent upon your requirements, and often a single system implements both patterns. Let's take a look at the two different approaches.
Pull/queue messaging
The pull pattern is an excellent design where you may have a worker process running, for example, resizing images. The API would receive the request and then add this to a queue for background processing. The worker process or processes read from the queue, retrieve the messages one by one, perform the required work, and then delete the message from the queue. Often, there is also a queue commonly called a dead letter queue. Should the worker process fail for any reason, then the message would be added to the dead letter queue. The dead letter queue allows the messages to be re-processed in the case of an incremental failure or for debugging purposes. Let's take a look at the following diagram...