This article is a simple way to integrate spring and ACTIVEMQ, only for reference learning, with a focus on understanding the concept.
1:JMS is a standard API developed by Sun to access message-oriented middleware (MOM), and the MOM component in this article is activeMq. You can download activeMq packages to the http://activemq.apache.org/download.html Web site,
It is very simple to use, after decompression directly run the D:\activemq-4.1.1\bin directory under the Activemq.bat file, start the service on it. And we are simply testing, so we do not need to configure the relevant content of Jndi. Service startup
Then we saw that the corresponding port was activated so that my mom component was ready ...
2: Next, we create a new Web project (I use MyEclipse), import related packages, recommend that you do not use the MyEclipse in the spring2.0 package, because several projects are because of this debugging for a long time, because the package has a problem. Oh.
Import Spring2.0.jar, Apache-activemq-4.1.1.jar, Commons-pool-1.2.jar, Long4j.jar, Commons-logging-1.1.jar files to the Lib directory. Next, create a new two XML file under Web-inf
<?xml version= "1.0" encoding= "UTF-8"?> <beans "xmlns=" xmlns: Xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:tx= "Http://www.springframework.org/schema/tx" xsi:
Schemalocation= "Http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/sprin G-beans-2.0.xsd http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2. 0.xsd "> <bean id=" connectionfactory "class=" Org.apache.activemq.pool.PooledConnectionFactory "> <PR Operty name= "ConnectionFactory" > <bean class= "org.apache.activemq.ActiveMQConnectionFactory" >
;p roperty name= "Brokerurl" > <value>tcp://localhost:61616</value> </property> </bean> </property> </bean> <bean id= "dest" class= "org.apache.activemq.command.Act Ivemqqueue "> <constructor-arG value= "Mydest"/> </bean> <bean id= "jmstemplate" class= "Org.springframework.jms.core.JmsTemplate" &
Gt <property name= "ConnectionFactory" ref= "ConnectionFactory" ></property> <property name= " Defaultdestination "ref=" dest "/> </bean> <bean id=" Messagesender "class=" Com.bo.impl.MessageSender " > <property name= "jmstemplate" ref= "jmstemplate" ></property> </bean> </beans>