Message Queue Architecture
The Message Queue service is composed of the following elements:
- Message Server
- Client Runtime
- Administered Objects
- Administration Tools
As shown in the figure, a Message Queue client uses the Java or C API to send or receive a message. These APIs are implemented in a Java or C-client runtime library, which does the actual work of creating connections to the broker and packaging the bits appropriately for the connection service requested. If the application uses administered objects, the client runtime locates these objects in an object store and uses them to configure the connection and to locate physical destinations. The broker routes and delivers the message. An administrator uses Message Queue administrative tools to manage the broker and to add administered objects to the object store.Message Server
The message server is composed of one or more brokers and performs message routing and delivery. It is the heart of the Message Queue service.
The message server consists of a single broker or a set of brokers working together (as a broker cluster) to perform message routing and delivery services. The broker is a process that performs the following tasks:
- The authentication of users and authorization of the operations they want to perform
- Sets up communication channels with clients
- Receives messages from producing clients and places them in their respective physical destinations
- Routes and delivers messages to one or more consuming clients
- Guarantees reliable delivery
- Provides data for monitoring system performance.4
Message client run time
The Message Queue client runtime provides client applications with an interface to the Message Queue service. The client runtime supports all operations needed for Message Queue clients to produce messages (send them to destinations) and to consume messages (retrieve them from destinations). - Java client runtime. Supplies Java client applications and components with all the objects needed to implement the JMS API and to interact with the Message Queue message server. These interface objects include connections, sessions, messages, message producers, and message consumers.
- C client runtime. Supplies C client applications and components with the C programming interfaces needed to interact with the Message Queue server. (The C client runtime supports a procedural version of the JMS API messaging model.)
Message production and consumption involve an interaction between clients and the client runtime, while message delivery is an interaction between the client runtime and the message server.
Application field
JMS (ActiveMQ is a JMS broker implementation) can be used as a mechanism to allow asynchronous request processing. You may wish to do this because the request take a long time to complete or because several parties may be interested in the actual request. Another reason for using it is to allow multiple clients (potentially written in different languages) to access information via JMS. ActiveMQ is a good example here because you can use the STOMP protocol to allow access from a C#/Java/Ruby client.
A real world example is that of a web application that is used to place an order for a particular customer. As part of placing that order (and storing it in a database) you may wish to carry a number of additional tasks:
Store the order in some sort of third party back-end system (such as SAP), Send an email to the customer to inform them their order has been placed.
To do this your application code would publish a message onto a JMS queue which includes an order id. One part of your application listening to the queue may respond to the event by taking the orderId, looking the order up in the database and then place that order with another third party system. Another part of your application may be responsible for taking the orderId and sending a confirmation email to the customer.