Application server sample code

 

Figure 1 summarizes the principles of ServerSessionPool and ServerSession functionality.

Figure 1. ServerSessionPool and ServerSession functionality

  1. The ConnectionConsumers get message references from the queue.

  2. Each ConnectionConsumer selects specific message references.

  3. The ConnectionConsumer buffer holds the selected message references.

  4. The ConnectionConsumer requests one or more ServerSessions from the ServerSessionPool.

  5. ServerSessions are allocated from the ServerSessionPool.

  6. The ConnectionConsumer assigns message references to the ServerSessions and starts the ServerSession threads running.

  7. Each ServerSession retrieves its referenced messages from the queue. It passes them to the onMessage method from the MessageListener that is associated with the JMS Session.

  8. After it completes its processing, the ServerSession is returned to the pool.

Normally, the application server supplies ServerSessionPool and ServerSession functionality. However, WebSphere MQ JMS is supplied with a simple implementation of these interfaces, with program source. These samples are stored in a subdirectory of the WebSphere MQ Java samples directory. The subdirectory is called jms\asf on Windows and jms/asf on the other platforms. To determine the WebSphere MQ Java samples directory for your platform, see Table 2.

These samples enable you to use the WebSphere MQ JMS ASF in a standalone environment (that is, you do not need a suitable application server). Also, they provide examples of how to implement these interfaces and take advantage of the WebSphere MQ JMS ASF. These examples are intended to aid both WebSphere MQ JMS users, and vendors of other application servers.


uj25640_