jondot / sneakers

A fast background processing framework for Ruby and RabbitMQ
https://github.com/jondot/sneakers
MIT License
2.24k stars 333 forks source link

Dead letter queue consumption issue #476

Closed TDliumin closed 1 year ago

TDliumin commented 1 year ago

Issue

When I consume the data of a dead letter queue named my-app.test.error, it occurred an error Unexpected error PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'my-app.test.error' in vhost 'stg': received the value 'undefined' of type 'void' but current is none.

Is this my own setting error ?

My code

  queue_name = ‘my-app.test.error'.freeze
  routing_key = 'my-app.test'.freeze

  WORKER_OPTIONS = {
    ack: true,
    heartbeat: 10,
    routing_key: routing_key,
    max_retries: Workers.system[:workers_max_retries],
    arguments: {
      'x-dead-letter-exchange' => nil,
      'x-dead-letter-routing-key' => nil,
    },
  }.freeze

  from_queue queue_name, WORKER_OPTIONS

  def perform(job_payload)
    params = JSON.parse(job_payload)

  end
michaelklishin commented 1 year ago

This seems to be a client-specific behavior where one client does not set the value (likely Sneakers via Bunny) but the client you try to use sets it to "undefined" instead of filtering out such values in argument tables.

Without knowing what client you are trying to consume from, the only suggestion I have is to use a passive declare (that will simply ensure that the queue is there, without a redeclaration and thus the property/argument equivalency check).

Clients usually filter out undefined/null/None values in attribute tables.

TDliumin commented 1 year ago

@michaelklishin Thank you for your reply. The dead letter queue I'm consuming is generated by the Sneakers framework, and I currently want to consume this queue. No matter what values I set for 'x-dead-letter-exchange' and 'x-dead-letter-routing-key', always occurs an error. My issue is like this issue.

It can work normally when using a similar setting to consume non-dead letter queues and only encounters problems when consuming dead letter queues.

Unexpected error PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'my-app.test.error' in vhost 'stg': received the value '' of type '' but current is none

Could you give me some guidance?