- Introduction to The Architecture
- JMS and the Web
- A Sample Application Using JMS Through a Web Client
- A Producer Web Client Application
- A Consumer Web Client Application
- Conclusion
A Sample Application Using JMS Through a Web Client
A web client that uses the JMS API does the same thing as a stand-alone client, but it performs this implementation in a different way. Stand-alone clients can produce messages and consume messages synchronously or asynchronously. Web components (either Java servlets or JSPs) can produce messages and consume messages synchronously. Therefore, the only difference between a web client and a stand-alone client is how they consume messages. Web components cannot consume messages asynchronously.
While developing a web-based client application on a JMS application, you must be very careful. Because synchronous consuming blocks the server and ties up server resources, you should avoid using the receive() method call in a web component while consuming messages. Instead, you should use the receive() method with a time parameter (receive(long parTimeOut) method) to avoid blocking server resources.
In the next two sections, I provide two sample JMS applications accessed by a web client. One is a message producer, and the other is a message consumer.