Exchange of JMS Services when a project is transferred from WebLogic to Tomcat

Source: Internet
Author: User

Configuring JMS in the Tomcat server

The project was originally using WebLogic's JMS service and spring's jmstemplate, so the configuration could not modify the code of the message operation in the project

First, download activemq Decompression After the start, access to http://localhost:8161/admin

Default account password admin:admin, click queue, create a new queue TestQueue1

Second, add context.xml under the tomcat/webapp/meta-inf

Configure the data source separately,activemq connection Factory, queue, import Activemq-all.jar

<resource name= "Jdbc/oracledb" auth= "Container"

Type= "Javax.sql.DataSource" password= "xx

"Username=" XX "

Driverclassname= "Oracle.jdbc.driver.OracleDriver"

Url= "Jdbc:oracle:thin:@192.168.0.0:1521:xx" maxidle= "2" maxwait= "5000"

Maxactive= "4"

factory= "Org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"/>

<resource name= "Jms/connectionfactory"

Auth= "Container"

Type= "Org.apache.activemq.ActiveMQConnectionFactory"

description= "JMS Connection Factory"

factory= "Org.apache.activemq.jndi.JNDIReferenceFactory"

Brokerurl= "tcp://localhost:61616"

Brokername= "Localactivemqbroker"/>

<resource name= "Jms/queue"

Auth= "Container"

Type= "Org.apache.activemq.command.ActiveMQQueue"

Description= "My Queue"

factory= "Org.apache.activemq.jndi.JNDIReferenceFactory"

Physicalname= "TestQueue1"/>

Third, configure the following information in the springbeans-jms.xml file:

<!--Connection Factory--

<bean id= "Jmsconnectionfactory" class= "Org.springframework.jndi.JndiObjectFactoryBean" >

<property name= "Jndiname" value= "Java:comp/env/jms/connectionfactory" ></property>

</bean>

<!--Queue---

<bean id= "Jmsqueue" class= "Org.springframework.jndi.JndiObjectFactoryBean"

Lazy-init= "true" >

<property name= "Jndiname" value= "Java:comp/env/jms/queue" ></property>

</bean>

<!--Spring JMS Template---

<bean id= "Jmstemplate" class= "Org.springframework.jms.core.JmsTemplate"

Lazy-init= "true" >

<property name= "ConnectionFactory" ref= "Jmsconnectionfactory" ></property>

<property name= "defaultdestination" ref= "Jmsqueue" ></property>

</bean>

<bean id= "JmsProducer" class= "Com.jyd.ebank.util.JmsProducer" >

<property name= "Jmstemplate" ref= "Jmstemplate"/>

</bean>

<bean id= "MessageListener" class= "Com.jyd.ebank.util.JmsListener"/>

<bean id= "Listenercontainer"

class= "Org.springframework.jms.listener.DefaultMessageListenerContainer" >

<property name= "Concurrentconsumers" value= "5"/>

<property name= "ConnectionFactory" ref= "Jmsconnectionfactory"/>

<property name= "Destination" ref= "Jmsqueue"/>

<property name= "MessageListener" ref= "MessageListener"/>

<property name= "Sessionacknowledgemodename" value= "Auto_acknowledge"/>

</bean>

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.