THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- In WebMDB project select WebContent/WEB-INF/geronimo-web.xml and modify the content with the one shown below.
Code Block title geronimo-web.xml borderStyle solid <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns8:web-app xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:ns2="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" xmlns:ns3="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:ns4="http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0" xmlns:ns5="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" xmlns:ns6="http://geronimo.apache.org/xml/ns/security-2.0" xmlns:ns7="http://java.sun.com/xml/ns/persistence" xmlns:ns8="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" xmlns:ns9="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"> <environment> <moduleId> <groupId>default</groupId> <artifactId>WebMDB</artifactId> <version>1.0</version> <type>car</type> </moduleId> <dependencies> <dependency> <groupId>default</groupId> <artifactId>MessageDrivenBean</artifactId> <version>1.0</version> <type>car</type> </dependency> <dependency> <groupId>org.apache.geronimo.configs</groupId> <artifactId>activemq-ra</artifactId> <version>2.1.1</version> <type>car</type> </dependency> </dependencies> </environment> <ns8:context-root>/WebMDB</ns8:context-root> <ns3:resource-ref> <ns3:ref-name>testfactory</ns3:ref-name> <ns3:resource-link>DefaultActiveMQConnectionFactory</ns3:resource-link> </ns3:resource-ref> </ns8:web-app>
- <dependency>- Defines the dependency of the application on ActiveMQ and MessageDrivenBean
- <ns3:resource-ref>- This tag is basically used to define connections that can be JDBC Connection, Java Mail connection or JMS Connection Factory. In our case we are using it for JMS Connection Factory.
- In MessageDrivenBean project select META-INF/openejb-jar.xml and modify it as follows
Code Block title openejb-jar.xml borderStyle solid <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.2" xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0" xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.2" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"> <sys:environment> <sys:moduleId> <sys:groupId>default</sys:groupId> <sys:artifactId>MessageDrivenBean</sys:artifactId> <sys:version>1.0</sys:version> <sys:type>car</sys:type> </sys:moduleId> <sys:dependencies> <sys:dependency> <sys:groupId>org.apache.geronimo.configs</sys:groupId> <sys:artifactId>activemq-ra</sys:artifactId> <sys:version>2.1.1</sys:version> <sys:type>car</sys:type> </sys:dependency> </sys:dependencies> </sys:environment> <enterprise-beans> <message-driven> <ejb-name>AdminMDB</ejb-name> <nam:resource-adapter> <nam:resource-link>ActiveMQ RA</nam:resource-link> </nam:resource-adapter> <activation-config> <activation-config-property> <activation-config-property-name> destination </activation-config-property-name> <activation-config-property-value> SendReceiveQueue </activation-config-property-value> </activation-config-property> <activation-config-property> <activation-config-property-name> destinationType </activation-config-property-name> <activation-config-property-value> javax.jms.Queue</activation-config-property-value> </activation-config-property> </activation-config> </message-driven> </enterprise-beans> </openejb-jar>
- <enterprise-beans>- This tag suggests that the usage of EJB's in our application.
- <message-driven>- This tag suggest the usage of MDB's in our application.
- <ejb-name>- Name of the ejb.
- <nam:resource-link>- Link for the resource adapter.
To learn more on MDB deployment plans refer Creating deployment plans section.Deploy and Run
- Export MessageDrivenBean.jar and WebMDB.war from eclipse as shown in the figure below
- Launch Administrative console and deploy the EJB and Web Application using Deploy New.
- Once done launch the web application with http://localhost:8080/WebMDB/.\\
- Fill the form as suggested in the figure and Select Submit.
- Once done check out the command prompt. Message Driven Bean has triggered and it displays the message currently on the queue.