'Why does camel route give Failed to send reply with payload error after calling the Message Consumption Listener?
I have defined a camel route in my file route builder like this :
from("timer:first-timer") .bean(new MsgConsumptionListener(),"receiveMessage")
.log(">>>> Body content is :::::::: ---> ${body}")
.log(">>> Name is ::::::: ------> ${body.Name}")
.setHeader("Name",method(MsgConsumptionListener.class))
.to("log:first-timer");
Inside the MsgConsumptionListener.java , I am consuming the message like this :
@Async
@JmsListener(destination = "MyQueue")
public String receiveMessage(final Message jsonMessage) throws JMSException {
String messageData = null;
log.info("Message has been received----->" +jsonMessage);
String rcvrName = null;
if(jsonMessage instanceof TextMessage) {
TextMessage textMessage = (TextMessage)jsonMessage;
messageData = textMessage.getText();
Map map = new Gson().fromJson(messageData, Map.class);
rcvrName = (String) map.get("Name");
log.info("Receiver Name----->" +rcvrName);
}
return rcvrName;
}
I can see the message is getting consumed , but the camel route gives the below error when it calls the listener :
c.f.i.listener.MsgConsumptionListener : Message has been received----->ActiveMQTextMessage {commandId = 5, responseRequired = true, destination = queue://MyQueue, transactionId = null, expiration = 0, timestamp = 1644257093499, arrival = 0, brokerInTime = 1644257093500, brokerOutTime = 1644298154164, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = org.apache.activemq.util.ByteSequence@4d7cdcac, marshalledProperties = null, dataStructure = null, redeliveryCounter = 1, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, jmsXGroupFirstForConsumer = false, text = {"Name":"Kunal"}}
c.f.i.listener.MsgConsumptionListener : Receiver Name----->Kunal
[ main] o.a.c.impl.engine.AbstractCamelContext : Routes startup summary (total:1 started:1)
[ main] o.a.c.impl.engine.AbstractCamelContext : Started route1 (timer://first-timer)
[ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.11.2 (camel-1) started in 724ms (build:72ms init:622ms start:30ms)
o.s.j.l.DefaultMessageListenerContainer : Execution of JMS message listener failed, and no ErrorHandler has been set.
org.springframework.jms.listener.adapter.ReplyFailureException: Failed to send reply with payload [bp_exchange.in]; nested exception is javax.jms.InvalidDestinationException: Cannot determine response destination: Request message does not contain reply-to destination, and no default response destination set.
[r://first-timer] c.f.i.listener.FileEventListener : Message has been received----->null
[r://first-timer] route1 : >>>
[r://first-timer] c.f.i.listener.FileEventListener : Message has been received----->null
[r://first-timer] route1 : >>> The file Name set in the header is :
[r://first-timer] c.f.i.listener.FileEventListener : Message has been received----->null
So the camel route is not able to get the message attribute Name and set it in the header . Does anybody know as to what the issue is and what I should be doing to get the message attribute in the route ?
My objective is to use the file route builder to call my MsgConsumption listener and whenever a message is dropped in the queue , I want the route to trigger the listener , consume the message and get the attribute Name from the message to be used for further processing .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
