RabbitMQ how to do routing by property?

228 views Asked by At

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.

0

There are 0 answers