As discussed at the beginning of this chapter, publish and subscribe messaging provides an alternative method of loosely coupled component interaction. In the following example, a message client sends a request for information on particular movies. As shown previously with the message queue example, the message is in an XML format, so parsing and processing the message is made simpler.
Creating a publish and subscribe client is similar to creating a message queue client. But instead of sending the message to a queue, we will publish it to a topic. The following code example demonstrates this process.
package examples.jms; import java.util.*; import javax.naming.*; import javax.jms.*; ...