Broker 10.5 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | Coding Messaging Client Applications | JMS Request-Reply Application with a Message Selector | Request-Reply Application: Description | Using a Second Messaging Thread
 
Using a Second Messaging Thread
In JMS, each session supports a single thread. For an application to support the reception of concurrent messages, the application must contain a session (thread context) for each message receiver.
The customer inquiry application constitutes one messaging thread: messages are sent from a requestor application and received asynchronously by a server. Adding a second thread requires that another session be created and message reception handled on that thread.
To demonstrate use of a second messaging thread, the example includes code for sending and receiving a single administrator command. The command is sent by an administrator client and received by the server application. When the server receives the command, it shuts itself down.
The following figure shows the execution flow for the example's second message reception thread.
The numbers in the figure correspond to the steps that occur when the shutdown command is issued:
Step
Description
1
The admin client application is started with the server shutdown command entered on the command line.
2
The command is copied to a JMS message and sent to the server.
3
The server extracts the command string from the message.
4
The server executes the command and shuts down.