Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bunny::Channel#default_exchange returns a new object each time #661

Closed
blowfishpro opened this issue May 12, 2023 · 0 comments
Closed

Bunny::Channel#default_exchange returns a new object each time #661

blowfishpro opened this issue May 12, 2023 · 0 comments
Milestone

Comments

@blowfishpro
Copy link

RabbitMQ version: 3.11.15, installed via homebrew
Ruby version: 3.2.2
Bunny version: 2.20.3

Overview

All the other Bunny::Channel methods that return an exchange look for the object first and return the existing one if it does not exist. But default_exchange returns a new object each time, and anything tied to the previous object is lost.

Example to reproduce the issue:

require' bunny'
session = Bunny::Session.new
session.start
channel = session.channel
channel.default_exchange.on_return { |*args| puts "dx1: on_message_return: #{args.inspect}" }
channel.default_exchange.publish('message1', mandatory: true, routing_key: 'no_such_queue') # or dx2

Expected: the on_return callback is called
Actual: the on_return callback is never called

Workaround

Instead of calling channel.default_exchange call channel.direct(AMQ::Protocol::EMPTY_STRING, no_declare: true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants