I am a novice to Apache Camel and is looking for a way to direct output of a route to an AMQP.
I could write a routine to send to AMQP myself, but I am looking for advice how it be done using Camel .to() when declaring a route? It is difficult to find a complete example online.
what I need to do:
All that I would like to do without involving XML configurations, but based on annotations or code.
Here is an example of how to do it:
from("direct://PublishToRabbitMQ")
.setHeader("rabbitmq.ROUTING_KEY", constant("SOMEROUTINGKEY"))
.setHeader("rabbitmq.EXCHANGE_NAME",constant("EXCHANGE_NAME"))
.setHeader("timestamp", constant(new Date(System.currentTimeMillis())))
.doTry()
.to("rabbitmq://localhost/EXCHANGE_NAME/?exchangeType=Topic&autoDelete=false&durable=false")
.convertBodyTo(String.class)
.end();
Add or remove parameters to suit your need.