Example of a Tomcat binding JMS application Server

Source: Internet
Author: User
Tags implement stomp tomcat
Server

JMS as the senior part of the Java EE has been shrouded in a veil of mystery, as the JMS Customizer Sun only prescribes the JMS specification, as many other sun products have been provided by several vendors to implement the specific. But as Tomcat and resin (announced at the beginning of this year all support the Java EE specification). These low-end but widely used servers themselves do not provide JMS support. Thankfully, OPENJMS and ACTIVEMQ two Open-source software provide plug-in support.

If you want to use JMS in a project that uses a few development frameworks like spring, although spring provides some support for JMS, after a while I've discovered that OO encapsulation has become a hindrance in the development process in some places. It's frustrating to implement code snippets such as listening, with callback (callbacks) something that is still not well fetched.

Here are some of the support for the JMS above Tomcat to do the finishing.

1. Naturally you need to download JMS implementations, such as: OPNERJMS or ActiveMQ. Download Address www.jmsopen.com or www.activeMQ.com

2. After the server download the specific configuration in the above two sites have a very detailed description, no longer enumerated.

3. And the integration of the Web server, first to configure the application of the Web.xml this file configuration is as follows:

       
        
         
        1  <context-param>2  <param-name>brokeruri</param-name>3  <param-value>/ Web-inf/activemq.xml</param-value>4  </context-param>56  <listener>7  < Listener-class>org.activemq.web.springbrokercontextlistener</listener-class>8  </listener>
       
        

Put this piece of code in the Web.xml. Note that the Activemq.xml file is the specific configuration of the JMS server:

       
        
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE beans Public "-//activemq//dtd//en" "Http://activemq.org/dtd/activemq.dtd" ><beans> <!--========    =============--> <!--ActiveMQ Broker Configuration--> <!--=====================--> <broker> <connector> <tcpservertransport uri= "tcp://localhost:61616" useasyncsend= "true" maxoutstandingmessage s= "/> </connector> <!--to enable STOMP support uncomment this <connector> &LT;SERVERTR Ansport uri= "stomp://localhost:61626"/> </connector>--> <persistence> <jdbcpersi Stence datasourceref= "Oracle-ds"/> </persistence> </broker> <!--=======================--> & lt;!  --JDBC DataSource configurations--> <!--=======================--> <!--the Derby DataSource that would be used by the Broker--> <bean id= "Derby-ds" class= "Org.apache.commons.dbcp.BasicDataS"Ource "destroy-method=" Close "> <property name=" driverclassname "> <value> org.apache.derby.jdbc.Em Beddeddriver </value> </property> <property name= "url" > <!--use a URL like ' Jdbc:hsqld B:hsql://localhost:9001 ' If you are want to connect to a remote hsqldb--> <value> jdbc:derby:derbydb;create= True </value> </property> <property name= "username" > <value></value> </pro perty> <property name= "password" > <value></value> </property> <property name= " Poolpreparedstatements "> <value>true</value> </property> </bean></beans>
       

At this point, you will see that the JMS server is already tied up when you start your tomcat.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.