Hi all
I am using the ProducerTemplate to send messages through RabbitMQ, with a
code like:

ProducerTemplate camelProducer = ...;
> Object body = "a body";
> Map<String, Object> headers = new HashMap<String, Object>(2);
> headers.put(RabbitMQConstants.DELIVERY_MODE, "2");
> camelProducer.*sendBodyAndHeaders*(endpoint, body, headers);


That code works ok, but I need some way to set the mandatory flag in true,
to handle unroutable messages, as is said at
http://www.rabbitmq.com/api-guide.html#returning

If I put a breakpoint at the basicPublish(*) methods
of com.rabbitmq.client.impl.ChannelN class, I can see that the camel
invocation comes from RabbitMQProducer, method basicPublish, line:

channel.basicPublish(exchange, routingKey, properties, body);


That line does not specify the mandatory flag, so the RabbitMQ code uses
false as default:

public void basicPublish(String exchange, String routingKey,
> BasicProperties props, byte[] body) throws IOException {
>         basicPublish(exchange, routingKey, *false*, props, body);
> }


Do you know if there is a hack to set the mandatory flag in true, while
sending a message to RabbitMQ by using the ProducerTemplate ? BTW I am
using camel 2.15.3

Thanks in advance.

Best regards,
Juan

Reply via email to