I am using Spring integration to connect to JMS Messaging queues. JMS Provider I am using is Apache ActiveMQ.
I have following class which reads JMS messages (having ServiceActivator
method):
@Component
public class MessageReader
{
@ServiceActivator
public Entity onMessage(Message<Entity> inboundMessage) {
System.out.println(" -------Message Read Start--------");
System.out.println(inboundMessage.getHeaders());
System.out.println(" -------Message Headers Reading completed--------");
Entity payload = null;
try{
payload = inboundMessage.getPayload();
System.out.println(" -------Message Read End--------");
}catch(Exception e){
e.printStackTrace();
}
return payload;
}
}
Over here, Entity is a POJO in my application.
While reading message from JMS-queue, I get following exception:
java.lang.ClassCastException: org.apache.activemq.command.ActiveMQObjectMessage cannot be cast to com.poc.pojo.Entity
How should I solve this?
Thanks