ACTIVEMQ and Spring Integration

Source: Internet
Author: User
Tags aop

First step: Referencing the associated jar package

                <dependency><groupid>org.springframework</groupid><artifactid>spring-jms</ artifactid></dependency><dependency><groupid>org.springframework</groupid>< Artifactid>spring-context-support</artifactid></dependency>    

Step Two: Configure ACTIVEMQ Integration Spring

<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://www.springframework.org/schema/beans" xmlns: context= "Http://www.springframework.org/schema/context" xmlns:p= "http://www.springframework.org/schema/p" xmlns: aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP" xmlns:tx= "Http://www.springframework.org/schema/tx" xmlns:xsi= " Http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" Http://www.springframework.org/schema/beans http ://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http ://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http ://www.springframework.org/schema/aop/spring-aop-4.2.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/TX/http Www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://www.springframework.org/schema/util/HTTP Www.springframework.org/schema/util/spring-util-4.2.xsd "><!--can actually produce connection connectionfactory, by the corresponding JMS Service vendors provide--><bean Id= "Targetconnectionfactory" class= "org.apache.activemq.ActiveMQConnectionFactory" ><property name= " Brokerurl "value=" tcp://192.168.25.168:61616 "/></bean><!-- Spring is used to manage the real connectionfactory connectionfactory--><bean id= "ConnectionFactory" class= " Org.springframework.jms.connection.SingleConnectionFactory "><!--target connectionfactory corresponds to the real can generate JMS Connection connectionfactory--><property name= "targetconnectionfactory" ref= "Targetconnectionfactory"/> </bean><!--Configure the JMS tool class provided by producer--><!--Spring, which can send messages, receive, etc.--><bean id= "jmstemplate" class= " Org.springframework.jms.core.JmsTemplate "><!--this connectionfactory corresponds to the ConnectionFactory object that we defined spring provides. --><property name= "ConnectionFactory" ref= "ConnectionFactory"/></bean><!--This is the queue destination, point-to-point-- <bean id= "queuedestination" class= "Org.apache.activemq.command.ActiveMQQueue" ><constructor-arg>< Value>spring-queue</value></constructor-arg></bean><!--This is the theme destination, one-to-many--><bean id= "topicdestination" class= "Org.apache.activemq.command.ActiveMQTopic" ><constructor-arg value= "topic"/></bean></beans>

 

<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://www.springframework.org/schema/beans" xmlns: context= "Http://www.springframework.org/schema/context" xmlns:p= "http://www.springframework.org/schema/p" xmlns: aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP" xmlns:tx= "Http://www.springframework.org/schema/tx" xmlns:xsi= " Http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" Http://www.springframework.org/schema/beans http ://www.springframework.org/schema/beans/spring-beans-4.2.xsdhttp://www.springframework.org/schema/context http ://www.springframework.org/schema/context/spring-context-4.2.xsdhttp://www.springframework.org/schema/aop http ://www.springframework.org/schema/aop/spring-aop-4.2.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/TX/http Www.springframework.org/schema/tx/spring-tx-4.2.xsdhttp://www.springframework.org/schema/util/HTTP Www.springframework.org/schema/util/spring-util-4.2.xsd "><!--can actually produce connection connectionfactory, by the corresponding JMS Service vendors provide--><bean Id= "Targetconnectionfactory" class= "org.apache.activemq.ActiveMQConnectionFactory" ><property name= " Brokerurl "value=" tcp://192.168.25.168:61616 "/></bean><!-- Spring is used to manage the real connectionfactory connectionfactory--><bean id= "ConnectionFactory" class= " Org.springframework.jms.connection.SingleConnectionFactory "><!--target connectionfactory corresponds to the real can generate JMS Connection connectionfactory--><property name= "targetconnectionfactory" ref= "Targetconnectionfactory"/> </bean><!--This is the queue destination, point-to-point--><bean id= "Queuedestination" class= " Org.apache.activemq.command.ActiveMQQueue "><constructor-arg><value>spring-queue</value> </constructor-arg></bean><!--This is the theme destination, one-to-many--><bean id= "topicdestination" class= " Org.apache.activemq.command.ActiveMQTopic "><constructor-arg value=" topic "/></bean><!--receive messages-- ><!--Configuration Listener--><bean id= "Mymessagelistener" class= "Cn.e3mall.search.listener.MyMessageListener"/&Gt;<!--Message monitoring container--><bean class= "Org.springframework.jms.listener.DefaultMessageListenerContainer" >< Property Name= "ConnectionFactory" ref= "connectionfactory"/><property name= "destination" ref= " Queuedestination "/><property name=" MessageListener "ref=" Mymessagelistener "/></bean></beans >

  

ACTIVEMQ and Spring Integration

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.