1

so I have been following this tutorial: http://www.rabbitmq.com/tutorials/tutorial-six-java.html, but I cant get it to work with a direct exchange.

Can someone help me out please by modifying the code so that it works with a direct exchange.

My objective: the user can chose which machine to send to, When they choose i want to bind to that machine and just send it to that machine. But it doesn't seem to be working when i change the queue declare to exchange declare. Any help would be greatly appriciated!!!

Thanks

Matteo
  • 37,680
  • 11
  • 100
  • 115

1 Answers1

0

In RabbitMQ you publish messages to exchanges, so the code you are seeing in the tutorial: channel.basicPublish("", "rpc_queue", props, message.getBytes());, means: send a message to the exchange "", using routing key "rpc_queue". That's the default or anon exchange discussed in tutorial one.

So if you want to send a message to a direct exchange, just change the empty exchange name for your exchange name.

Now, why do you want to do it that way? Why can't you instead of declaring an "rpc_queue", you declare a queue per machine, and address them by their names, in basicPublish?

old_sound
  • 2,243
  • 1
  • 13
  • 16