Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Anchortoptop

Enterprise messaging has become an increasingly important component of loosely coupled, reliable enterprise frameworks. This is due in large part to the proliferation of enterprise applications and disparate enterprise resources, and the increasing need to integrate these applications into cohesive systems. Over the years Messaging and Message Oriented Middleware (MOM) has provided this integration proprietory manner. Introduction of Java Messaging Service (JMS) as a standard, eliminated many of the disadvantages in proprietory MOM based products. In addition,Message Driven Beans(MDBs) introduced together with Enterprise Java Beans 2.0 have served to get the best out of existing investments in J2EE application servers. Most of the J2EE application servers in modern era are acting as a MOM with a whole lot of value added services to JMS. As a J2EE 1.4 certified application server, Apache Geronimo comes into the party with support of JMS integrating with one of the best breed open source messaging frameworks, ActiveMQ. This article will provide you with a way to use JMS for your enterprise application scenario both as a local and remotely reffered environments with Geronimo and ActiveMQ.

...

Overview of JMS in Geronimo/ActiveMQ Enviroment Anchoroverviewoverview

Geronimo server comes with a JMS server and application components that can access JMS resources like connection factories, topics and queues from it. This JMS server is also known as message broker. The default message broker supported by Geronimo is ActiveMQ, usually does not need to be changed since it is a mature and feature-rich JMS product. This implementation uses inbuilt Derby database for the message persistent features.

ActiveMQ supports a large variety of transports (such as TCP, SSL, UDP, multicast, intra-JVM, and NIO) and client interactions (such as push, pull, and publish/subscribe). In the Geronimo context ActiveMQ supports MDBs, which are EJBs that consume JMS messages. It allows JMS applications to take J2EE specific features from Geronimo and application components such as JSPs, Servlets or EJBs utilizing JMS. Geronimo has implemented this JMS API in an abstract layer to support any JMS provider. It has achieved this feature by supporting J2EE Connector (JCA) specification. The JCA 1.5 specification details the contracts required between the application server and the driver supplied by ActiveMQ (resource adapter). Applications deployed in the Geronimo access ActiveMQ message broker only through this resource adapter(RA).

Application Overview Anchorapplicationapplication

Order processing application has two defined message queues to recieve orders and consignments. Order requests can be generated and sent via the company's web application. When order requests are recieved to the order queue, a MDB will be triggered. It will carry out the next level of order request processing by saving those requests in to a server repository. Those saved order requests will be processed by a company employee later.

...

Finally, the core of the order placement application will be deployed as an EAR to the application server. Overview of the contents of EAR is given in the following depiction.

...

...

First, we will look at defining the connection factories and queues in the Geronimo server using jms-resource-plan.xml. It defines two JMS queues and a common queue connection factory to access them.

...

...

In this application there is a MDB that will listen on OrderQueue. openejb-jar.xml defines Geronimo specific features of that MDB. It links OrderRecv MDB with OrderQueue via CommonConnectionFactory.

...

...

geronimo-application.xml and application.xml define the main components of the EAR. Both EJB component and Web archive information are given in these files as usual.

...

...

Order Processing Web application sends messages to the Order Queue. OrderSenderServlet will handle the relevant order request generation and the sending. web.xml of the archive has the relevant configurations for the both queue connection factory and the queue, which is essential to refer resources in a local enviroment.

...

...

...

Please note that this web application supports Servlet 2.4 specification. Some of the configurations in older versions (2.3) are slightly different than given in the above web.xml.

geronimo-web.xml will act as a mediator between defined JMS resources in the application server and the web.xml.

...

...

The next important part of this sample application is how to send messages from out side the application server context. Consignment sender will handle it for the application as given below.

...

...

How to listen on a JMS queue other than a MDB? The answer to this question can be found in the consignment reciever application.

...

...

Tools used

The tools used for developing and building the order placement application are:

...

Configuring, Building and Deploying the Sample Application Anchor configureconfigure

Download the order processing application from the following link:
Order

...

Set the correct paths for the xdoclet.home and geronimo.home directories to perform the application build process correctly.

...

...

...

This build script depends on XDoclet version 1.2.3 and Geronimo 1.2. Also make sure to use "/" as you directory separator in Windows environment when you are setting the properties.

...

...

order_mgmt.properties file given is shared among four defferent application components. You may have to change those properties according to your local enviroment as given below.

...

If you deploy one of these application components out side of application server, make sure you change the relevant network property in the above mentioned property file.

...

Testing of the Sample Application Anchor testingtesting

Core business functionality of the order processing application is shared among the three different client applications. Testing of each client is can be done as given.

...

ant run-send-client -Dsendfile=<home>/Order/config/sample-consignment.xmlnoformat

bgColor#000000borderStylesolid root@karthi-laptop:/home/Karthiga/Doc-1.2/Sample APPS/JMS and MDB/Order# ant run-send-client -Dsendfile=config/sample-consignment.xml Buildfile: build.xml run-send-client: [java] Working directory ignored when same JVM is used. [java] Consignment Sent !!! BUILD SUCCESSFUL

Consignment Listener Remote Application

Listener application to the consignment queue. It will download the consignment requests in the local repository. As in the above mentioned application, navigate to the Order folder through command prompt. Then, issue the following command to start listening on the consignment queue.

ant run-recv-client No FormatbgColor

#000000borderStylesolid root@karthi-laptop:/home/Karthiga/Doc-1.2/Sample APPS/JMS and MDB/Order# ant run-recv-client Buildfile: build.xml run-recv-client: client: [java] Start Listening Consignment Data [java] Received a Consignment: [java] <?xml version="1.0" encoding="UTF-8"?> [java] <Consignment id="001"> [java] <Branch id="123"/> [java] <Orders> [java] <Order orderId="234" custId="889" qty="90" model="101"/> [java] <Order orderId="235" custId="776" qty="69" model="102"/> [java] <Order orderId="236" custId="245" qty="74" model="103"/> [java] <Order orderId="237" custId="232" qty="55" model="105"/> [java] <Order orderId="238" custId="354" qty="44" model="106"/> [java] <Order orderId="239" custId="267" qty="97" model="107"/> [java] </Orders> [java] </Consignment>

Summary Anchorsummarysummary

This article has demonstrated the use of JMS features in Apache Geronimo with the ActiveMQ JMS server.It provides a hypothetical example which extensively used JMS features.

...