0

I want to do RabbitMQ routing (via exchanges) by properties or more specific by the property type.

This is my sending code:

AMQP.BasicProperties.Builder propsBuilder = new AMQP.BasicProperties.Builder();
propsBuilder.type(typeName);
channel.basicPublish(targetExchange, "", true, props, data);

I tried it with exchange type headers, but if i understand it correctly "headers" are only the headers set WITHIN the PROPERTY "headers" and not the properties themselves.

This is my receiving binding code (not working as intended):

channel.exchangeDeclare(exchangeName, "headers", false, true, null);

HashMap<String, Object> filter = new HashMap<String, Object>();
filter.put("x-match", "all");
filter.put("type", "HEARTBEAT");
channel.queueBind(queueName, exchangeName, "", filter);

I was also wondering if i can set up the same filtering when using an exchange routing to another exchange. I believe it should be possible.

Frederic Leitenberger
  • 1,949
  • 24
  • 32
  • If you are going to use just one k/v pair on your headers, why not use the direct exchange instead? Yes, you can use a headers exchange bound to another exchange – old_sound Jun 23 '15 at 08:58
  • Our system already uses the header field `type` to transport the information about what kind of package it is. For monitoring we would like to send a copy of only a few token types to another receiver (in copy). If a routing based on the header would be possible it would be the easiest solution. We would only need to add or modify some exchanges. – Frederic Leitenberger Jun 27 '15 at 21:58

0 Answers0