Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The company reffered in this sample application sells one specific item in both retail and whole sale (wholesale) markets. All the placed orders in the application has (have) to be autorized (authorized) by a company sales employee before delevering(delivering) goods to the customer. To(For) the whole sale (wholesale) market, (the) company has placed their agents all over the country. They send their orders as a bunch at once, which is called a consignment. End users place their orders using (the) company web site while agents send their consignments with a special software insalled (installed) in their premises. All the cosignments (consignments) must be approved by the comany (company) GM (General Manager) before it is handed over to a sales employee.
This is a typical application to use JMS as a solution because both cosignment(consignment) and order requests are processed in asynchronous manner.

...

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).

Code Block
java
java
|-Order.ear
   |-OrderEjb.jar
	|-META-INF
	    |- ejb-jar.xml
	    |- openejb-jar.xml
   |-OrderWeb.war
	|-jsp
            |- index.jsp
	    |- error.jsp
	|-WEB-INF
	    |- web.xml
	    |- geronimo-web.xml
	    |- classes
   |-META-INF
        |- application.xml
        |- geronimo-application.xml

First, we will look at how to define (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.

Code Block
xml
xml
borderStylesolid
titlejms-resource-plan.xml
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1">
    <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId>
            <dep:groupId>samples</dep:groupId>
            <dep:artifactId>jms-resources</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>rar</dep:type>
        </dep:moduleId>
        <dep:dependencies>
            <dep:dependency>
                <dep:groupId>geronimo</dep:groupId>
                <dep:artifactId>activemq-broker</dep:artifactId>
                <dep:type>car</dep:type>
            </dep:dependency>
        </dep:dependencies>
    </dep:environment>
    <resourceadapter>
        <resourceadapter-instance>
            <resourceadapter-name>CommonConnectionFactory</resourceadapter-name>
            <config-property-setting name="Password">geronimo</config-property-setting>
            <config-property-setting name="UserName">geronimo</config-property-setting>
            <nam:workmanager xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1">
                <nam:gbean-link>DefaultWorkManager</nam:gbean-link>
            </nam:workmanager>
        </resourceadapter-instance>
        <outbound-resourceadapter>
            <connection-definition>
                <connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>
                <connectiondefinition-instance>
                    <name>CommonConnectionFactory</name>
                    <connectionmanager>
                        <xa-transaction>
                            <transaction-caching/>
                        </xa-transaction>
                        <single-pool>
                            <match-one/>
                        </single-pool>
                    </connectionmanager>
                </connectiondefinition-instance>
            </connection-definition>
        </outbound-resourceadapter>
    </resourceadapter>
    <adminobject>
        <adminobject-interface>javax.jms.Queue</adminobject-interface>
        <adminobject-class>org.activemq.message.ActiveMQQueue</adminobject-class>
        <adminobject-instance>
            <message-destination-name>OrderQueue</message-destination-name>
            <config-property-setting name="PhysicalName">OrderQueue</config-property-setting>
        </adminobject-instance>
		<adminobject-instance>
            <message-destination-name>ConsignmentQueue</message-destination-name>
            <config-property-setting name="PhysicalName">ConsignmentQueue</config-property-setting>
        </adminobject-instance>
    </adminobject>
    <adminobject>
        <adminobject-interface>javax.jms.Topic</adminobject-interface>
        <adminobject-class>org.activemq.message.ActiveMQTopic</adminobject-class>
    </adminobject>
</connector>

...

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

Code Block
xml
xml
borderStylesolid
titlegeronimo-application.xml
<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.1">
  <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
    <dep:moduleId>
      <dep:groupId>samples</dep:groupId>
      <dep:artifactId>Order</dep:artifactId>
      <dep:version>1.0</dep:version>
      <dep:type>car</dep:type>
    </dep:moduleId>
    <dep:dependencies/>
    <dep:hidden-classes/>
    <dep:non-overridable-classes/>
  </dep:environment> 
</application>

...

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.

Code Block
xml
xml
borderStylesolid
titleweb.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
		version="2.4">
	
	<servlet>
		<display-name>OrderSenderServlet</display-name>
		<servlet-name>OrderSenderServlet</servlet-name>
		<servlet-class>org.apache.geronimo.samples.order.web.OrderSenderServlet</servlet-class>
	</servlet>
	
	<servlet-mapping>
		<servlet-name>OrderSenderServlet</servlet-name>
		<url-pattern>/order</url-pattern>
	</servlet-mapping>	
	
	<resource-ref>
	    <res-ref-name>jms/CommonConnectionFactory</res-ref-name>
	    <res-type>javax.jms.QueueConnectionFactory</res-type>
	    <res-auth>Container</res-auth>
	    	<res-sharing-scope>Shareable</res-sharing-scope>
 	</resource-ref>
	
	<message-destination-ref>
	    <message-destination-ref-name>jms/OrderQueue</message-destination-ref-name>
	    <message-destination-type>javax.jms.Queue</message-destination-type>
	    <message-destination-usage>Produces</message-destination-usage>
	    <message-destination-link>OrderQueue</message-destination-link>
	</message-destination-ref>
	
	<welcome-file-list>
		<welcome-file>/jsp/index.jsp</welcome-file>
	</welcome-file-list>
	
</web-app>
Note

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

...

Configuration of the application consists of creating JMS resources and accessing them via defferent (different) sorts of enviroments (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 logged in to (logging) into the Geronimo console.

  1. Select Deploy New link from the Console Navigation in the left.
  2. Load the <geronimo_home>/repository/geronimo/ge-activemq-rar/1.1/ge-activemq-rar-1.1.rar file to the Archive field.
  3. Load the Order/config/jms-resource-plan.xml file to the Plan input field.
  4. Press Install button. Make sure Start app after install is selected when this deployment happens
  5. Upon successful installation message, verify the deployment (by) traversing JMS resources link. It will display the connection factory and two JMS queues.

...

This application has two very important property files in the config folder namely build.properties and order_mgmt.properties. Build process of the application is (delete-is) entirely depends on the build.propeties and application will use order_mgmt.properties to load application related properties.

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

...

Note

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

...

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 refered(reffered) by the remote client applications. Now you are ready to deploy order processing application in to into the Geronimo Application server.

...

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 Sytem's (System's) security configuration if you are connecting from a remote machine.

...

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

...