Search code examples
rabbitmqbunny

How to publish message to existing exchange


I'm playing with Bunny, and trying to publish message to existing queue. Unfortunately inside Bunny documentation are snipent for consumer creation but not for produser. So for example when I try to bind to some exchange, it throws an error

PRECONDITION_FAILED - cannot redeclare exchange 'test' in vhost '/' with different type, durable, internal or autodelete value

Code:

conn = Bunny.new()
conn.start
ch = conn.create_channel
x = ch.direct("test")

Do you know why it's trying to redeclare.

Maybe I need first bind to a queue?

Thanks for any help.


Solution

  • The error message is telling you that you tried to redeclare an exchange but you changed some of its arguments.

    If you are just testing, then delete the exchange and re run your script.

    We also have a set of tutorials here: http://www.rabbitmq.com/getstarted.html