Introduction
In non-JMS J2EE architecture, the client and the enterprise beans a function on the basis of the request-response paradigm. In most cases, a session bean acts as a request interceptor and passes on the requests to the other entity or session beans, which are designed to do the actual work. This architecture is referred to as the session façade.
Session Façade is shown in the figure below: The Session bean in the middle passes the requests to other beans and the responses to the client.

Figure 1: Non-JMS J2EE Architecture
The drawback of session façade architecture is that session bean and entity bean methods, work on synchronous mode, which effectively means that when the client calls the beans with a request, it waits for a response. This can be overcome by including JMS in this kind of architecture. In such a scenario, the JMS Server and a Message-Driven bean, together, they take the place of a session bean interceptor.
However, what they receive is not a request, but a message which they acknowledge. Internally, the Message-Driven bean still uses request-response with other enterprise beans. This architecture is referred to as a message façade. The main advantage of the message façade is that the client sends a message to the JMS server, but does not wait for any response. Figure 2 illustrates a message façade. The JMS server is instrumental in passing messages and acknowledgments between the clients and the Message-Driven bean.

Figure 2 : JMS J2EE Architecture
Message- Driven Bean that Sends and Receives Messages
Message-Driven bean can be designed to both send and receives messages to separate queues. You can develop this kind of a Message-Driven bean, by adding all the message handling code in the onMessage() method. In the code below, the onMessage() method is executed when the Message-Driven bean receives a message using receiveQueue. The received message is stored in a TextMessage object and the characters, FWD: are added to the message. A message producer using sendQueue is created and the method TextMessage object is sent across to it.
Source Code

Join the conversation! Your thoughts help the community grow.