activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ismail Emre Kartoglu <ismailemrekarto...@gmail.com>
Subject Rabbitmq component headers
Date Tue, 20 Sep 2016 20:45:50 GMT
Hello Camel users,

I have a question regarding the camel-rabbitmq component. The following code sends the message
“test” to exchange “A” with routing key “B”:


from("timer:test?period=5000").process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                exchange.getOut().setBody("test", String.class);
                exchange.getOut().getHeaders().put("rabbitmq.EXCHANGE_NAME", "A”);   **
                exchange.getOut().getHeaders().put("rabbitmq.ROUTING_KEY", "B”);   **
            }
        })
 .to("rabbitmq://localhost/A?username=guest&password=guest&routingKey=B&threadPoolSize=1&autoAck=false");



However when I comment out the lines with **, the message does not get sent. Is this an expected
behaviour? I found this stack overflow post, essentially discussing the same issue: http://stackoverflow.com/questions/22449086/apache-camel-rabbitmq-endpoint-not-creating
<http://stackoverflow.com/questions/22449086/apache-camel-rabbitmq-endpoint-not-creating>
.

There is a paragraph at http://camel.apache.org/rabbitmq.html <http://camel.apache.org/rabbitmq.html>
that says

"Headers are set by the consumer once the message is received. The producer will also set
the headers for downstream processors once the exchange has taken place. Any headers set prior
to production that the producer sets will be overridden.”

The last sentence seems to suggest that the behaviour I described here is expected. My question
then is would it not make more sense if we did not have to specifically set the headers in
the out message?


Kind regards,
Ismail
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message