ActiveMQ (): ActiveMQ combined with spring development--recommendations

Source: Internet
Author: User

1. The camel framework supports a large number of enterprise integration models, which can greatly simplify the large number of services and complex message flows between integrated components. The spring framework focuses more on simplicity and supports only basic best practices.

2. The core architecture of the spring message is jmstemplate, which isolates the tedious operations like opening, closing sessions and producer, so application developers simply need to focus on the actual business logic.

However, jmstemplate damage the performance of ACTIVEMQ's pooledconnectionfactory to the caching mechanism of session and message producer.

3, the new spring inside, you can set org.springframework.jms.connection.CachingConnectionFactory sessioncachesize, or simply use the ACTIVEMQ

Pooledconnectionfactory, as follows:

    <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.brokerurl}</value></ Property><property name= "UserName"  value= "${activemq.username}" ></property>         <property name= "Password"  value= "${activemq.password}" ></property>    </bean></property><property name= " MaxConnections " value=" ${activemq.maxconnections} "></property>    </bean 

4. The Jmstemplate receive () Call is not recommended because all calls on the jmstemplate are synchronous, which means that the calling thread needs to be blocked until the method returns, which has a significant impact on performance.

5. Use Defaultmessagelistenercontainer, which allows you to receive messages asynchronously and cache session and message consumer, and also dynamically increase or decrease the number of listeners based on the number of messages.

<!--consumer listener--><bean id= "Jmscontainer" class= " Org.springframework.jms.listener.DefaultMessageListenerContainer "> <property name=" connectionfactory "ref=" Jmsfactory "/> <property name=" destination "ref=" Destinationtopic "/> <property name=" MessageListener "R ef= "MessageListener"/></bean>


This article is from "I Love Big gold" blog, please be sure to keep this source http://1754966750.blog.51cto.com/7455444/1916382

ActiveMQ (): ActiveMQ combined with spring development--recommendations

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.