Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Serializing & Deserializing objects through ObjectMessage

886634Sep 13 2011 — edited Sep 14 2011
Hi,

I'm having trouble sending objects/instances of a class (Data) through the message queue. I also made Data to be serializable.
public class Data implements Serializable {
...
}
The following are snippets of code from the Message producer side:
objectMessage = mySess.createObjectMessage();
MessageProducer myMsgProducer = mySess.createProducer(myQueue);
Data e = new Data();
objectMessage.setObject(e);
myMsgProducer.send(objectMessage);
And the following are snippets of code from the message consumer:
public void onMessage(Message message) {
...
             if(message instanceof ObjectMessage ){
	    try{
	    	ObjectMessage objMsg = (ObjectMessage) message;
	    	Data myData = (Data)objMsg.getObject();
	    }
	    catch(JMSException e){
	    	System.out.println("Exception occured: " + e.toString());
	    }
}
The result of attempting to cast the objMsg to a Data is an exception thrown.

i did noticed however, that when I was debugging the message consumer, that the byteArrayInputStream values for both message and objMsg are null meaning that the data is not being sent or received. Any help would be greatly appreciated, thanks!

Edited by: 883631 on Sep 13, 2011 4:09 PM

Edited by: EJP on 14/09/2011 09:22: added {noformat}
{noformat} tags. Please use them.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 12 2011
Added on Sep 13 2011
4 comments
1,703 views