...
- Overview of JMS in Geronimo/ActiveMQ Enviroment
- Application Overview
- Configuring, Building and Deploying the Sample Application
- Testing of the Sample Application
- Summary
Overview of JMS in Geronimo/ActiveMQ Enviroment
Anchor | ||||
---|---|---|---|---|
|
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 been 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
Anchor | ||||
---|---|---|---|---|
|
Order processing application has two defined message queues to recieve orders and consignments. Order requests can be generated and send by 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.
...
The following figure gives the overall architecture of the order processing application.
Application contents
The order placement application consist of following list of packages and classes.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
System.out.println("Start Listening Consignment Data "); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(propLoader.getValue(PROVIDER_URL)); connection = (QueueConnection)connectionFactory.createConnection(); connection.start(); session = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(propLoader.getValue(QUEUE_NAME)); consumer = session.createConsumer(queue); while(true){ Message message = consumer.receive(); processMessage(message); } |
Tools used
The tools used for developing and building the order placement application are:
XDoclet
XDoclet is an open source code generation engine. It enables Attribute-Oriented Programming for java. In short, this means that you can add more significance to your code by adding meta data (attributes) to your java sources. This is done in special JavaDoc tags.
Although XDoclet originated as a tool for creating EJBs, it has evolved into a general-purpose code generation engine. XDoclet consists of a core and a constantly growing number of modules. It is fairly straightforward to write new modules if there is a need for a new kind of component.
http://xdoclet.sourceforge.net/xdoclet/index.html
Eclipse
The Eclipse IDE was used for development of the sample application. This is a very powerful and popular open source development tool. It has integration plug-ins for the Geronimo too. Eclipse can be downloaded from the following URL:
http://www.eclipse.org
Apache Ant
Ant is a pure Java build tool. It is used for building the war files for the Inventory application. Ant can be downloaded from the following URL:
http://ant.apache.org
Configuring, Building and Deploying the Sample Application
Anchor | ||||
---|---|---|---|---|
|
Download the order processing application from the following link:
Order
After decompressing the given file, the Order directory will be created.
Configuring
Configuration of the application consists of creating JMS resources and accessing them via different sorts of environments.
Creating JMS Specific Resources
All JMS specific resource information can be found in the config/jms-resource-plan.xml file. Follow the given instructions to deployment, after logging into the Geronimo console.
- Select Deploy New link from the Console Navigation in the left.
- Load the <geronimo_home>/repository/geronimo/ge-activemq-rar/1.1/ge-activemq-rar-1.1.rar file to the Archive field.
- Load the Order/config/jms-resource-plan.xml file to the Plan input field.
- Press Install button. Make sure Start app after install is selected when this deployment happens
- Upon successful installation message, verify the deployment by traversing JMS resources link. It will display the connection factory and two JMS queues.
Modify Property Files
This application has two very important property files in the config folder namely build.properties and order_mgmt.properties. Build process of the application entirely depends on the build.propeties and application will use order_mgmt.properties to load application related properties.
...
Note |
---|
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. |
Building
Use a command prompt to navigate into the Order directory and just give ant command to build. It will create the Order.ear, recvclient.jar and sendclient.jar under the Order/releases folder. Also note it will create a lib folder and copy list of jar files reffered by the remote client applications. Now you are ready to deploy order processing application into the Geronimo Application server.
Deploying
Deploying Order processing sample application is pretty much the same as the deployment of JMS resources.
- Travel Deploy New from the Console Navigation.
- Load Order.ear from Order/releases folder in to the Archive input box.
- Press Install button to deploy application in the server.
Testing of the Sample Application
Anchor | ||||
---|---|---|---|---|
|
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.
Order Placement Web Application
To test the sample web application open a browser and type http://localhost:8080/Order. It will forward you in to the Order Management Welcome page. Then user has to fill the necessary information for the order placement and submit it.
Consignment Placement Remote Application
This application will send consignment requests to the consignment queue. It will take consignment file as a command line argument and send it to the relevant queue. For the testing of this application a sample consignment has been given with the appication archive as Order/config/sample-consignment.xml. First travel to the Order/releases from a command prompt and give the following command.
...
No Format bgColor #000000 borderStyle solid
lsf@lsf-laptop:~/workspace/Order/releases$ java -jar sendclient.jar /home/lsf/workspace/Order/config/sample-consignment.xml
30/08/2006 09:21:00 org.activemq.ActiveMQConnection statusChanged
INFO: channel status changed: Channel: TcpTransportChannel: Socket[addr=localhost/127.0.0.1,port=61616,localport=45177] has connected
Consignment Sent !!!
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, first travel to the Order/releases from a command prompt. After that issue the following command to start listening on the consignment queue.
...
Note |
---|
Always consider lib folder inside of releases are a part of this client application. It contains library files you need to add to your class path to call a JMS application. Check your Operating System's security configuration if you are connecting from a remote machine. |
Summary
Anchor | ||||
---|---|---|---|---|
|
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.
...