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