Requires Free Membership to View
JMS is an application programming interface (API) abstraction of common concepts found in all MOM systems. JMS does not define wire protocols or message-content formats.
The single parameter to the onMessage (Message msg) method is of type javax.jms.Message and it is up to the MDB programmer to cast the Message object to one of the five JMS message types: TextMessage, ObjectMessage, MapMessage, BytesMessage and StreamMessage.
You can create your own asynchronous, JMS-enabled, message listener/receiver and make calls to a service-logic object from its onMessage callback, as in the following example:
public class MyJMSReceiver implements MessageListener
{
public MyJMSReceiver()
{
// initialize JMS topic/queue connection here
}
public void onMessage(Message msg)
{
// Message received
BusinessService busService = unmarshalMessage(msg);
Document response = busService.execute();
publishToResponseQueue(response);
}
private BusinessService unmarshalMessage(Message msg)
{
// perform message-to-service conversion here
return aBusinessServiceInstance;
}
}
Continued in part 2.
This was first published in October 2004

Join the conversationComment
Share
Comments
Results
Contribute to the conversation