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_work
is bounded toex_main
withrk_work
- DLX of
q_work
isex_retry
- DLX Routing Key of
q_work
iswork
-
q_retry_work
is bounded toex_retry
withrk_work
- DLX of
q_retry_work
isex_main
- DLX Routing Key of
q_retry_work
iswork
- TTL of the
q_retry_work
is30s
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)