Rabbit MQ is an opensource message broker. We can publish messages to exchanges and queues can be bound to exchange with routing keys. Consumers will consume the payloads from the queues and so the application will work as intended.
Lets assume for some reason application couldn't process the payload and it rejects it, and we need to retry it with some delay? This is not rocket science, but lemme show you how I would have done it.
Pre-Conditions
-
q_workis bounded toex_mainwithrk_work - DLX of
q_workisex_retry - DLX Routing Key of
q_workiswork -
q_retry_workis bounded toex_retrywithrk_work - DLX of
q_retry_workisex_main - DLX Routing Key of
q_retry_workiswork - TTL of the
q_retry_workis30s
Producers publishes messages to ex_main.
Messages with rk_work routing key is immediately pushed to q_work.
The application will consume or reject messages.
Rejected messages are dropped to ex_retry and messages with rk_work will immediately pushed to q_retry_work.
Since no one is consuming from q_retry_work and after 30s it will dropped the messages to its DLX, which is ex_main.

Top comments (0)