Beginner Activemq, wrote a configuration file with spring

Source: Internet
Author: User

1: The database uses the DBCP configuration.

<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource"
destroy-method= "Close" >
<property name= "Driverclassname" value= "${jdbc.driverclassname}"/>
<property name= "url" value= "${jdbc.url}"/>
<property name= "username" value= "${jdbc.username}"/>
<property name= "Password" value= "${jdbc.password}"/>
<property name= "minpoolsize" value= "${jdbc.minpoolsize}"/>
<property name= "maxpoolsize" value= "${jdbc.maxpoolsize}"/>
<property name= "initialpoolsize" value= "${jdbc.initialpoolsize}"/>

<!--maximum idle time, unused in 60 seconds, the connection is discarded. If 0, it will never be discarded. The default is 0--
<property name= "MaxIdleTime" value= "${jdbc.maxidletime}"/>
</bean>

2: Configure ConnectionFactory link Factory
<bean id= "Jmsfactory" class= "Org.apache.activemq.pool.PooledConnectionFactory"
destroy-method= "Stop" >
<property name= "ConnectionFactory" >
<bean class= "Org.apache.activemq.ActiveMQConnectionFactory" >
<property name= "Brokerurl" value= "${activemq.url}"/>
</bean>
</property>
<property name= "MaxConnections" value= "${activemq.maxconnections}" ></property>
</bean>

3: Set the MQ mode to queue for asynchronous receive.

<bean id= "Destination" class= "Org.apache.activemq.command.ActiveMQQueue" >

<constructor-arg index= "0" value= "${activemq.destination}" ></constructor-arg>
</bean>

4: Your Consumer implementation class, handling the main function that receives the message.
<bean id= "Consumer" class= "Com.myself.jms.msgaccepter.action.ConsumerAction" >
<property name= "" ref= "" ></property>
</bean>

5: Message monitoring container, here unified implementation of the ACTINMQ message receiving mechanism.
<bean id= "Listenercontainer" class= "Org.springframework.jms.listener.DefaultMessageListenerContainer" >
<property name= "Concurrentconsumers" value= "${activemq.consumers}"/>
<property name= "ConnectionFactory" ref= "Jmsfactory"/>
<property name= "Destination" ref= "Destination"/>
<property name= "MessageListener" ref= "consumer"/>
</bean>

The values within the 6:$ are recorded through the properties file and support the changes.

Beginner Activemq, wrote a configuration file with spring

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.