Giter Club home page Giter Club logo

Comments (6)

slot avatar slot commented on July 1, 2024 1

It supports dead lettering by configuration:

old_sound_rabbit_mq:
    producers:
        work_producer:
            connection: default
            exchange_options: {name: work-exchange, type: direct}

    consumers:
        work_consumer:
            connection: default
            exchange_options: {name: work-exchange, type: direct}
            queue_options:    {name: work-queue, arguments: {'x-dead-letter-exchange': ['S', 'error-exchange']}}
            callback: work_consumer_callback

    error_consumer:
        connection: default
        exchange_options: {name: error-exchange, type: direct}
        queue_options:    {name: error-queue}
        callback: error_consumer_callback

So if you publish a message with the work consumer and the message gets rejected, RabbitMQ will transfer the message to the error_queue.

Note: Currently you can not reject the message with requeue=false using this bundle. You can configure a TTL for the message but your consumer will redo the message until TTL is reached. An example for the above with a TTL of 5 sec.

queue_options:    {name: work-queue, arguments: {'x-dead-letter-exchange': ['S', 'error-exchange'], 'x-message-ttl': ['I', 5000]}}

An improvement to reject messages with requeue=false is in this pull request https://github.com/videlalvaro/RabbitMqBundle/pull/109

from rabbitmqbundle.

arvenil avatar arvenil commented on July 1, 2024

Hi, since pull request is closed for about 5 months then is this working? Can you reject message with requeue=false?
EDIT: Just checked this out - it works! Thanks! :)

from rabbitmqbundle.

iLukey avatar iLukey commented on July 1, 2024

Hey all,

I'm aware this is a very old issue, but the solution doesn't seem to cover all use-cases.

In the scenario where my route is to publish a message to a fanout exchange, wherein one of a number of consumers fails, I want to dead-letter that message to the DLX - which is of type 'topic' - to a queue of a similar name as the original.

The config format here seems to be restricted to just one queue per DLX. Moreover, the example given, the error_consumer is at the same level of nesting as the 'consumers' key, but it needs to fall under that level of nesting.

Furthermore, there should ideally be more than one error_consumer block allowed as well, so that logical grouping can occur (allowing for multiple DLXs). This example might help explain what I mean:

I have two ways to create an order - the UI and an API. I have two inbound exchanges which are pushed to when an order has been created via either method:

  • order.created
  • order.api.created

Both of these exchanges are of type fanout, and both have the same three queues bound to them:

  • send_email
  • send_sms
  • add_note

In every scenario, let's assume that the latter two consumers work just fine, but sending an email is broken. After my TTL expires for each of them, they automatically get pushed to their respective DLX, order.created.dead_lettered or order.api.created.dead_lettered.

Both of these exchanges are of type topic, and the messages are dead-lettered with the routing key 'send_email' - the same as the original queue.

In each DLX, there are the following queues, and associated routing keys:

  • send_email.failed - send_email
  • send_sms.failed - send_sms
  • add_note.failed - add_note

So, to summarize, the config would need to allow for:

  • Multiple DLXs
  • Multiple queues per DLX (to support type of 'topic' and 'fanout')

The reason for two exchanges is to logically separate the two types of message - despite them currently being routed to the same three queues. In future, they may warrant their own queues, or queues which are specific to the order creation source (UI or API) alongside the more generic queues (think if the message format is different between the two).

As it stands, we have to specify one - and only one - DLX and DLX queue per config as I understand it, meaning that the other DLXs, and any additional DLX queues, need to be defined manually and wont be captured in the 'setup-fabric' call.

from rabbitmqbundle.

github-actions avatar github-actions commented on July 1, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from rabbitmqbundle.

github-actions avatar github-actions commented on July 1, 2024

This issue was closed because it has been stalled for 10 days with no activity.

from rabbitmqbundle.

Gyvastis avatar Gyvastis commented on July 1, 2024

It supports dead lettering by configuration:

old_sound_rabbit_mq:
    producers:
        work_producer:
            connection: default
            exchange_options: {name: work-exchange, type: direct}

    consumers:
        work_consumer:
            connection: default
            exchange_options: {name: work-exchange, type: direct}
            queue_options:    {name: work-queue, arguments: {'x-dead-letter-exchange': ['S', 'error-exchange']}}
            callback: work_consumer_callback

    error_consumer:
        connection: default
        exchange_options: {name: error-exchange, type: direct}
        queue_options:    {name: error-queue}
        callback: error_consumer_callback

So if you publish a message with the work consumer and the message gets rejected, RabbitMQ will transfer the message to the error_queue.

Note: Currently you can not reject the message with requeue=false using this bundle. You can configure a TTL for the message but your consumer will redo the message until TTL is reached. An example for the above with a TTL of 5 sec.

queue_options:    {name: work-queue, arguments: {'x-dead-letter-exchange': ['S', 'error-exchange'], 'x-message-ttl': ['I', 5000]}}

An improvement to reject messages with requeue=false is in this pull request https://github.com/videlalvaro/RabbitMqBundle/pull/109

Thanks for the comment. Spent half a day trying to figure out how to make it work with this bundle realising that it doesn't really work as per RabbitMQ documentation.

from rabbitmqbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.