Coupling, in the development world, is a
measure of how dependent two entities are upon each other.
Programmers make decisions everyday (consciously or otherwise) that
affect coupling: class coupling, API coupling, application
Coupling between applications isn’t necessarily
bad, but too much coupling can make your enterprise software hard
to manage. It can also reduce your development options when you’re
expanding software or writing new applications or services for your
company. The Java Message Service (JMS) can help reduce
dependencies between applications, while still allowing them to
communicate with and take advantage of each other’s resources.
JMS normally involves at least three
components: two JMS clients and the JMS server. The two clients
communicate with each other through the JMS server. JMS clients are
regular applications that use the JMS API to send and receive
The JMS server can be any application that
implements the JMS specification. Some JMS servers are part of
larger applications; others are solely dedicated to JMS tasks.
There are many third-party commercial and some open source JMS
servers available from which to choose.
Applications can choose to communicate with one
another using JMS in one of two ways: JMS topics or JMS queues.
Topics and queues differ in a few ways, but the most significant
way is in their approach to delivery.
JMS topics receive messages from a JMS client
and distribute those messages to all JMS clients that are
registered as topic listeners. JMS queues, on the other hand,
distribute messages to only one client, no matter how many are
registered as queue listeners. If two or more clients are
subscribed to a queue and a message is stored in the queue, only
one of the clients will receive the message. The specification does
not define which client will receive the message.
Whether you’re using topics or queues, the type
of data you pass in your messages is up to you. Some programmers
send business objects through their messaging systems, while other
programmers send XML messages as text to reduce coupling even
If you haven’t used JMS before, perhaps it’s
because you’ve never had a reason. If you’ve been writing your own
messaging systems, then, hopefully, you’ll be able to take
advantage of the JMS API.
JMS has been around for a few years now and has
proven to be a practical technology. Check out this
JMS tutorial, and then get out there and take a look for
Delivered each Thursday, our free Java newsletter provides insight and hands-on tips you need to unlock the full potential of this programming language. Automatically sign up today!