Java Reference
In-Depth Information
application. With an application built using
JMS
in the Publish-Subscribe mode,
you can use
JMX
to build a management application that uses the messaging
capabilities in a non-intrusive manner.
For example, imagine that an integration workflow tool drives a set of applica-
tions in a sequenced manner by using
JMS
messaging to signal the start of the
next step in a workflow. If the tool uses the Publish-Subscribe method for driving
the workflow, you can create an MBean that subscribes to the messages sent out
by the tool. In this manner, you can monitor the status of the tool and workflow
without interfering or accessing it directly. An MBean used this way can acquire
knowledge of the internal operations of the workflow tool without your having to
write any special access code. The MBean can be a generic
JMS
subscriber, and
therefore can work with many different types of message-publishing applications.
In addition, you can rapidly construct a management application that takes
control of the workflow system for cases of debugging or testing. A management
application can start workflows directly from the management system, or even
change the operation of the workflow by publishing its own messages.
JMS
pro-
vides a convenient mechanism for you to integrate your management system
with other applications.
13.3 Driving a home theater system
To demonstrate how you can combine
JMX
with a
JMS
application, we will describe
an automated home theater system. Suppose you work for a company that devel-
ops home theater control applications. Your company is a value-added provider
of a lighting control system. The lighting control system uses
JMS
messaging to
drive components based on control commands received from a remote control.
The software that receives the lighting commands also allows macros to be defined.
Macro capability allows scenes to be defined and executed—for example, a “roman-
tic” macro might dim the lights and play soft music.
JMX
is used not only to provide the macro capability, but also to provide man-
agement access into the home theater system. The application uses a controller
MBean that listens for all messages from the lighting system and publishes
device control messages that execute different functions that make up a macro.
These messages are published to a message bus using
JMS
. Figure 13.1 shows the
architecture for this application.
As you can see, the controller MBean will subscribe to control messages just
like the lighting control command processor. When receiving a particular message,
it will check to see if it has a macro defined for that message. If so, it will then