I need a reference please to a multiple routing keys binded queue.
You see, I created a queue and binded it once with
channel.queuebind()
and another time with yet again
channel.queuebind()
until i got this two bindings on the same queue.
but upon publishing - only the first bounded message was transfered successfully.
(I even replaced the orders and still - only the first. so my publishing is ok)
What i didnt do - is define the channel.basicConsumer with a new subscriber.
should I do it ? I want the old subsciver to get more messages. what did I do wrong?
Here is a list of my queues is
you can see that amq.gen-4ae4QUbSNevC/RgM+8C9CA== is binded to two keys.
but the message goes only to the first key
Listing queues ...
amq.gen-4ae4QUbSNevC/RgM+8C9CA== 0
amq.gen-sgZK0bSc0W3QEXda8m1vIQ== 0
PositionsQueue 1
...done.
rabbitmqctl.bat list_bindings
Listing bindings ...
exchange PositionsQueue queue PositionsQueue []
exchange amq.gen-4ae4QUbSNevC/RgM+8C9CA== queue amq.gen-4ae4QUbSNevC/RgM+8C9CA==
exchange amq.gen-sgZK0bSc0W3QEXda8m1vIQ== queue amq.gen- sgZK0bSc0W3QEXda8m1vIQ==
Positions_Exchange exchange amq.gen-4ae4QUbSNevC/RgM+8C9CA== queue Account:Account1
Positions_Exchange exchange amq.gen-4ae4QUbSNevC/RgM+8C9CA== queue Portfolio:Portfolio1
...done.
10x a lot
Edit:
producer
channel.basicPublish(exchangeName, routingKey, MessageProperties.MINIMAL_BASIC, messageBodyBytes);
consumer
channel.exchangeDeclare(exchangeName, "direct", durable);
QueueName = channel.queueDeclare(queueName, durable, exclusive, autoDelete, arguments).getQueue();
channel.queueBind(queueName, exchangeName, routingKey);
boolean noAck = false;
queueingConsumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, noAck, queueingConsumer);
Multiple bindingsIt is perfectly legal to bind multiple queues with the same binding key. In our example we could add a binding between X and Q1 with binding key black. In that case, the direct exchange will behave like fanout and will broadcast the message to all the matching queues.
Use multiple queues and consumers Queues are single-threaded in RabbitMQ, and one queue can handle up to about 50 thousand messages. You will achieve better throughput on a multi-core system if you have multiple queues and consumers and if you have as many queues as cores on the underlying node(s).
In this type of exchange, messages are sent to queues based on the routing key. This means that messages sent to a topic exchange must have a specific routing key that must be a list of words, delimited by dots (example, 'acs. deviceoperations. ').
In RabbitMQ, we can have multiple consumers listening from one queue. This is good for fast procesing, but not so good for message ordering.
You can follow this way:
channel.queueBind(queueName, exchangeName, "k1"); //k1 is first routing key
channel.queueBind(queueName, exchangeName, "k2"); //k2 is second routing key
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With