Hello group, I'm trying to implement the sending and receiving of object messages. The class is already serializable and I can send it without problems: Sonic.Jms.Message Msg = Sess.createObjectMessage(MP); Prod.send(Msg);
Hello group, I'm trying to implement the sending and receiving of object messages. The class is already serializable and I can send it without problems:
Sonic.Jms.Message Msg = Sess.createObjectMessage(MP);
MP is the instance of the class I'm sending.
My problem is at the receiving side, the message is triggering the onMessage event and I already have a variable with the definition of the class, but, what method should I use?
I see the getObjectProperty method from the Message class but don't know what name to use as property.
Should I use another method?
Thanks in advance.
javax.jms.Message has the getObjectProperty(String name) method. This is used to get JMS properties (cast as an Object) -- so you might do 'getObjectProperty("JMSCorrelationID").
What you want is to get the message's body. To do this, you need to get the accessor appropriate to the subclass of message. So in the onMessage(msg) method, you want to:
so something like.
public void onMessage( javax.jms.Message aMessage)
// Cast the message as a Object message, if possible.
// Otherwise report that invalid message arrived.
if (aMessage instanceof javax.jms.ObjectMessage)
javax.jms.ObjectMessage objMessage = (javax.jms.ObjectMessage) aMessage;
Object MP = objMessage.getObject();
catch (javax.jms.JMSException jmse)
System.out.println ("warning: Message arrived but cannot be " +
"processed as a javax.jms.ObjectMessage.");
catch (java.lang.RuntimeException rte)
See the following doc in your install-dir/Docs7.6/api
Excellent, thank you very much William