wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes MapMessage vs HashMap in setObjectMessage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "MapMessage vs HashMap in setObjectMessage" Watch "MapMessage vs HashMap in setObjectMessage" New topic
Author

MapMessage vs HashMap in setObjectMessage

Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
I need to pass data consisting of name,value pairs from a JMS Publisher to an MDB. I am not sure which option would be better....

1. MapMessage or
2. setObjectMessage() using the HashMap object..
Note: HashMap implements Serializable interface, so I reckon it might be OK to be used in setObjectMessage.
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Vishwa,

In my opinion MapMessage should be the best choice, if you intend to send collections of primitive data type (or their wrappers). First because MapMessages suppose to perform better than ObjectMessage, which adds the serialization extra-cost when passing data across application boundaries. Secondly adding new name-value pairs to the MapMessage is not going to break your code. Another drawback of using ObjectMessage is that it relies on the sender and receiver having the same exact version of the class and sometimes this might be a pain in the b� The only two reasons I�m aware about that should convince one to use the ObjectMessage are to have an object-oriented approach for sending/receiving messages. In your case though, since the object itself is a HashMap, you�re kind of loosing this feature. Another limitation of MapMessage is that you cannot send any type of data, but only primitive and their Java wrappers.
Regards.


I think, therefore I exist -- Rene Descartes
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
thanks Valentin.
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
You're very welcome Vishwa
 
GeeCON Prague 2014
 
subject: MapMessage vs HashMap in setObjectMessage