• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question JMS ObjectMessage  RSS feed

 
velli fieldman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a question concerning the sending of a ObjectMessage to an Message Driven Bean.
As I understand, when I send a ObjectMessage to the MessageQue the Object which is attached to my ObjectMessage is copied and readonly. I can only alter the object using the clearbody method.
What I don't understand is what that exactly means for my object.
Let's say that the attached object is a HttpSession object, and i want my MDB to place a reference to another object into the HttpSession.
I want to know if the following is true,
When afterwards a servlet asks for a reference to the object placed in the Session Object by the Message Driven Bean, he will not find it because it's not the same HttpSession object. Since the Object message just copies the object.
If this is not true, where do i screw up?
Many Regards,
velli
 
Bill Dudney
Author
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi velli,
You really should not ever be doing anything near what you suggest with an http session. The core j2ee patterns book has Context Object as one means of dealing with the session object but I would be curious about your requirements before saying that you need this pattern.
The object is 'copied' onto the queue because its seralized into a byte stream then deseralized before the onMessage method is called. Once inside the onMessage you can make any changes you'd like but as you say, its a copy so the original client will not see these changes.
Perhaps you could consider a stateful session that the client could get info from and the MDB could update with new info?
I'd need to know more about your requirements before I could offer more advice.
Best of luck, and I hope this helps.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm with Bill. Don't try it -- it won't work. First of all, all of the Objects placed in an ObjectMessage must be Serializable -- which an HttpSession is not. I think Bill's Stateful session idea (or his idea to look at the Core J2EE patterns book) is a better one.
Kyle
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!