To receive messages, applications that use extended messaging use a receiver bean, which can be a message-driven bean or a session bean:
When a receiver bean gets a message, it can invoke another method passing either the JMS Message, or a set of parameters extracted from the message content. The invoked method can be contained in the receiver bean or in another enterprise bean (which is the preferred application structure). If data mapping is used, the method invoked by a receiver bean is unaware of the original JMS message.
In addition to receiving messages, extended messaging enables applications to reply to received messages in either of the following ways:
If a receiver bean gets a JMS message, then depending upon the programming model (associated with the receiver bean by WebSphere Studio), one of the following interactions occurs:
The receiver bean provides an anonymous invocation in the form of a method call. The data passed to the method is either the JMS message (if no data mapping is invoked) or a set of parameters mapped from the JMS message. The receiver bean cannot return a reply to this invocation. This mode of interaction can be used with point-to-point or publish/subscribe messaging.
If the receiver bean gets a message, it invokes another method either in the same bean or another enterprise bean. When the method returns, the data returned from that call is mapped to a JMS message and sent to the reply destination specified in the original request message. The type of reply destination (queue or topic) must be the same as the type used by the original request received.
For a receiver bean deployed as a message-driven bean, the reply is returned (using the bean's ReplySender method) to the replyTo destination specified in the original request message.
For a receiver bean deployed as a session bean, the reply is returned to the destination defined in the input port for the receiver bean.
In addition to the asynchronous model of this interaction, this mode of interaction enables a method to send multiple replies to a single invocation.