Is this really the way to receive POJOs with JMS?
public void onMessage(Message msg) {
ObjectMessage objMsg = (ObjectMessage) msg;
if(objMsg.getObject() instanceof <<sometype>>) {
//do something
}
}
Do I have to cast to ObjectMessage. Actually then i have to check if msg is castable to ObjectMessage too.
or do i miss something?
thx
AFAIK, that's it. It's pretty rare to mix different message types, and different object types inside the message, in a single destination (queue or topic), though. So you might skip the instanceof checks if you know that only ObjectMessages containing SomeType objects are expected.