Ala
Ala

Reputation: 107

Analysing messages residing in a queue RabbitMQ

I have several Java Clients sending messages to a queue using RabbitMQ default exchange.

I want to be able to analyse the messages inside of the queue (if they are not consumed obviously), identify the sender of the message and if a Client is sending too many messages then bind a special queue so that this client sends messages to that queue .

I am new with RabbitMQ so What I would like to know is :

Any help would be much appreciated.

Upvotes: 0

Views: 211

Answers (1)

Gabriele Santomaggio
Gabriele Santomaggio

Reputation: 22750

Is it possible to append a client ID as a header in RabbitMQ?

you can use the headers field on BasicProperties

Map<String, Object> headers = new HashMap<String, Object>();
headers.put("myclientid",  22222);

channel.basicPublish(exchangeName, routingKey,
             new AMQP.BasicProperties.Builder()
               .headers(headers)
               .build()),
               messageBodyBytes);

How to create a special queue for clients with much workload?

There are no "special" queues, you can add more consumers to the same queue, in case you have an high workload. See https://www.rabbitmq.com/tutorials/tutorial-two-java.html

Is it possible to analyse messages residing in a queue?

You can use the API basic_get without ACK the message, in this way you can read a messages without remove them from the queue

Upvotes: 1

Related Questions