You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by bu...@apache.org on 2015/01/29 20:21:39 UTC
svn commit: r938261 - in /websites/production/activemq/content:
cache/main.pageCache spring-support.html
Author: buildbot
Date: Thu Jan 29 19:21:39 2015
New Revision: 938261
Log:
Production update by buildbot for activemq
Modified:
websites/production/activemq/content/cache/main.pageCache
websites/production/activemq/content/spring-support.html
Modified: websites/production/activemq/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/activemq/content/spring-support.html
==============================================================================
--- websites/production/activemq/content/spring-support.html (original)
+++ websites/production/activemq/content/spring-support.html Thu Jan 29 19:21:39 2015
@@ -81,42 +81,22 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><p>We fully support Spring for configuration of the JMS client side as well as for configuring the JMS Message Broker.<br clear="none">
-There is a great <a shape="rect" class="external-link" href="http://codedependents.com/2009/10/16/efficient-lightweight-jms-with-spring-and-activemq/" rel="nofollow">article</a> on using Spring with ActiveMQ - I'd recommend reading it first.</p>
-
-<h2 id="SpringSupport-ConfiguringtheJMSclient">Configuring the JMS client</h2>
-
-<p>To configure an ActiveMQ JMS client in Spring it is just a simple matter of configuring an instance of ActiveMQConnectionFactory within a standard Spring XML configuration file like any other bean. There are <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/spring/">several examples and test cases</a> available and <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/xbean/spring.xml">this one</a> shows how to construct an ActiveMQConnectionFactory in Spring which is then passed into a Spring JmsTemplate for use by some POJOs.</p>
-
-<p>e.g. the following fragment of XML shows us creating a JMS connection factory for ActiveMQ connecting to a remote broker on a specific host name and port.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-<bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
+<div class="wiki-content maincontent"><p>We fully support Spring for configuration of the JMS client side as well as for configuring the JMS Message Broker.<br clear="none"> There is a great <a shape="rect" class="external-link" href="http://codedependents.com/2009/10/16/efficient-lightweight-jms-with-spring-and-activemq/" rel="nofollow">article</a> on using Spring with ActiveMQ - I'd recommend reading it first.</p><h2 id="SpringSupport-ConfiguringtheJMSclient">Configuring the JMS client</h2><p>To configure an ActiveMQ JMS client in Spring it is just a simple matter of configuring an instance of ActiveMQConnectionFactory within a standard Spring XML configuration file like any other bean. There are <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/">several examples and test cases</a> available and <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/activem
q/trunk/activemq-unit-tests/src/test/resources/org/apache/activemq/xbean/spring.xml">this one</a> shows how to construct an ActiveMQConnectionFactory in Spring which is then passed into a Spring JmsTemplate for use by some POJOs.</p><p>e.g. the following fragment of XML shows us creating a JMS connection factory for ActiveMQ connecting to a remote broker on a specific host name and port.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>tcp://localhost:61616</value>
</property>
</bean>
]]></script>
-</div></div>
-<p>The following shows how to use Zeroconf to discover the available brokers to connect to.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-<bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
+</div></div><p>The following shows how to use Zeroconf to discover the available brokers to connect to.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>zeroconf://_activemq.broker.development.</value>
</property>
</bean>
]]></script>
-</div></div>
-<p>From 1.1 of ActiveMQ onwards you can also use JNDI to configure ActiveMQ within Spring. <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/test/resources/spring-jndi.xml">This example</a> shows how to configure Spring using ActiveMQ's <a shape="rect" href="jndi-support.html">JNDI Support</a>.</p>
-
-<h3 id="SpringSupport-UsingSpring">Using Spring</h3>
-
-<p>If you are using the new <a shape="rect" class="external-link" href="http://static.springframework.org/spring/docs/2.0.x/reference/xsd-config.html" rel="nofollow">XML Schema-based configuration</a> of Spring 2.0 you can embed the ActiveMQ broker XML inside any regular Spring.xml file without requiring the above factory bean. e.g. here is an example of a regular Spring XML file in Spring 2.0 which also configures a broker.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-<beans
+</div></div><p>From 1.1 of ActiveMQ onwards you can also use JNDI to configure ActiveMQ within Spring. <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/activemq/trunk/activemq-unit-tests/src/test/resources/spring-jndi.xml">This example</a> shows how to configure Spring using ActiveMQ's <a shape="rect" href="jndi-support.html">JNDI Support</a>.</p><h3 id="SpringSupport-UsingSpring">Using Spring</h3><p>If you are using the new <a shape="rect" class="external-link" href="http://static.springframework.org/spring/docs/2.0.x/reference/xsd-config.html" rel="nofollow">XML Schema-based configuration</a> of Spring 2.0 you can embed the ActiveMQ broker XML inside any regular Spring.xml file without requiring the above factory bean. e.g. here is an example of a regular Spring XML file in Spring 2.0 which also configures a broker.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -132,23 +112,8 @@ There is a great <a shape="rect" class="
<amq:connectionFactory id="jmsFactory" brokerURL="vm://localhost"/>
</beans>
]]></script>
-</div></div>
-<p>This allows you to configure JMS artifacts like destinations and connection factories together with the entire broker.</p>
-
-<h2 id="SpringSupport-WorkingwithSpring'sJmsTemplate">Working with Spring's JmsTemplate</h2>
-
-<p>Spring supports a handy abstraction, JmsTemplate, which allows you to hide some of the lower level JMS details when sending messages etc.</p>
-
-<p>Please be aware that there are a number of <a shape="rect" href="jmstemplate-gotchas.html">JmsTemplate Gotchas</a> to be careful of.</p>
-
-<p>One thing to bear in mind with JmsTemplate is that by default it will create a new connection, session, producer for each message sent - then close them all down again. This is very inefficient! It is done like this to work in EJB containers which tend to use a special ConnectionFactory which does pooling.</p>
-
-<p>If you are not using a JCA container to manage your JMS connections, we recommend you use our pooling JMS connection provider, (org.apache.activemq.pool.PooledConnectionFactory) from the <code>activemq-pool</code> library, which will pool the JMS resources to work efficiently with Spring's JmsTemplate or with EJBs.</p>
-
-<p>e.g.</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-<!-- a pooling based JMS provider -->
+</div></div><p>This allows you to configure JMS artifacts like destinations and connection factories together with the entire broker.</p><h2 id="SpringSupport-WorkingwithSpring'sJmsTemplate">Working with Spring's JmsTemplate</h2><p>Spring supports a handy abstraction, JmsTemplate, which allows you to hide some of the lower level JMS details when sending messages etc.</p><p>Please be aware that there are a number of <a shape="rect" href="jmstemplate-gotchas.html">JmsTemplate Gotchas</a> to be careful of.</p><p>One thing to bear in mind with JmsTemplate is that by default it will create a new connection, session, producer for each message sent - then close them all down again. This is very inefficient! It is done like this to work in EJB containers which tend to use a special ConnectionFactory which does pooling.</p><p>If you are not using a JCA container to manage your JMS connections, we recommend you use our pooling JMS connection provider, (org.apache.activemq.pool.PooledConnectio
nFactory) from the <code>activemq-pool</code> library, which will pool the JMS resources to work efficiently with Spring's JmsTemplate or with EJBs.</p><p>e.g.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<!-- a pooling based JMS provider -->
<bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
@@ -166,27 +131,7 @@ There is a great <a shape="rect" class="
</property>
</bean>
]]></script>
-</div></div>
-
-<p>The <code>PooledConnectionFactory</code> supports the pooling of Connection, Session and MessageProducer instances so it can be used with tools like <a shape="rect" class="external-link" href="http://camel.apache.org/activemq.html">Camel</a> and Spring's <a shape="rect" class="external-link" href="http://activemq.apache.org/spring-support.html">JmsTemplate and MessagListenerContainer </a>. Connections, sessions and producers are returned to a pool after use so that they can be reused later without having to undergo the cost of creating them again.</p>
-
-<p>Note: while the <code>PooledConnectionFactory</code> does allow the creation of a collection of active consumers, it does not 'pool' consumers. Pooling makes sense for connections, sessions and producers, which can be seldom-used resources, are expensive to create and can remain idle a minimal cost. Consumers, on the other hand, are usually just created at startup and left going, handling incoming messages as they come. When a consumer is complete, it's preferred to shut down it down rather than leave it idle and return it to a pool for later reuse: this is because, even if the consumer is idle, ActiveMQ will keep delivering messages to the consumer's prefetch buffer, where they'll get held up until the consumer is active again.</p>
-
-<p>If you are creating a collection of consumers (for example, for multi-threaded message consumption), you should consider keeping a low prefetch value (e.g. 10 or 20), to ensure that all messages don't end up going to just one of the consumers. </p>
-
-<p>We do also have a pooling JMS ConnectionFactory for use inside a JCA / MDB container (org.apache.activemq.ra.InboundConnectionProxyFactory), when using our JCA Resource Adapter which will reuse the same JMS connection/session which is being used for inbound messages.</p>
-
-<h2 id="SpringSupport-ConsumingJMSfrominsideSpring">Consuming JMS from inside Spring</h2>
-
-<p>Spring's <a shape="rect" class="external-link" href="http://static.springsource.org/spring/docs/2.5.x/reference/jms.html#jms-mdp" rel="nofollow">MessagListenerContainer</a> should be used for message consumption. This provides all the power of MDBs - efficient JMS consumption and pooling of the message listeners - but without requiring a full EJB container. </p>
-
-<p>You can use the <code>activemq-pool</code> <code>org.apache.activemq.pool.PooledConnectionFactory</code> for efficient pooling of the connections and sessions for your collection of consumers, or you can use the Spring JMS <code>org.springframework.jms.connection.CachingConnectionFactory</code> to achieve the same effect.</p>
-
-
-<h2 id="SpringSupport-MoreInformation">More Information</h2>
-
-<p>Also check out the following blogs for information about using Spring JMS with ActiveMQ: </p>
-<ul><li><a shape="rect" class="external-link" href="http://codedependents.com/2010/03/04/synchronous-request-response-with-activemq-and-spring/" rel="nofollow">Synchronous Request Response with ActiveMQ and Spring</a></li><li><a shape="rect" class="external-link" href="http://bsnyderblog.blogspot.com/2010/02/using-spring-jmstemplate-to-send-jms.html" rel="nofollow">Using Spring to Send JMS Messages</a></li><li><a shape="rect" class="external-link" href="http://bsnyderblog.blogspot.com/2010/02/using-spring-to-receive-jms-messages.html" rel="nofollow">Using Spring to Receive JMS Messages</a></li><li><a shape="rect" class="external-link" href="http://bsnyderblog.blogspot.com/2010/05/tuning-jms-message-consumption-in.html" rel="nofollow">Tuning JMS Message Consumption In Spring</a></li></ul></div>
+</div></div><p>The <code>PooledConnectionFactory</code> supports the pooling of Connection, Session and MessageProducer instances so it can be used with tools like <a shape="rect" class="external-link" href="http://camel.apache.org/activemq.html">Camel</a> and Spring's <a shape="rect" class="external-link" href="http://activemq.apache.org/spring-support.html">JmsTemplate and MessagListenerContainer </a>. Connections, sessions and producers are returned to a pool after use so that they can be reused later without having to undergo the cost of creating them again.</p><p>Note: while the <code>PooledConnectionFactory</code> does allow the creation of a collection of active consumers, it does not 'pool' consumers. Pooling makes sense for connections, sessions and producers, which can be seldom-used resources, are expensive to create and can remain idle a minimal cost. Consumers, on the other hand, are usually just created at startup and left going, handling incoming messages as they come
. When a consumer is complete, it's preferred to shut down it down rather than leave it idle and return it to a pool for later reuse: this is because, even if the consumer is idle, ActiveMQ will keep delivering messages to the consumer's prefetch buffer, where they'll get held up until the consumer is active again.</p><p>If you are creating a collection of consumers (for example, for multi-threaded message consumption), you should consider keeping a low prefetch value (e.g. 10 or 20), to ensure that all messages don't end up going to just one of the consumers.</p><p>We do also have a pooling JMS ConnectionFactory for use inside a JCA / MDB container (org.apache.activemq.ra.InboundConnectionProxyFactory), when using our JCA Resource Adapter which will reuse the same JMS connection/session which is being used for inbound messages.</p><h2 id="SpringSupport-ConsumingJMSfrominsideSpring">Consuming JMS from inside Spring</h2><p>Spring's <a shape="rect" class="external-link" href="http://s
tatic.springsource.org/spring/docs/2.5.x/reference/jms.html#jms-mdp" rel="nofollow">MessagListenerContainer</a> should be used for message consumption. This provides all the power of MDBs - efficient JMS consumption and pooling of the message listeners - but without requiring a full EJB container.</p><p>You can use the <code>activemq-pool</code> <code>org.apache.activemq.pool.PooledConnectionFactory</code> for efficient pooling of the connections and sessions for your collection of consumers, or you can use the Spring JMS <code>org.springframework.jms.connection.CachingConnectionFactory</code> to achieve the same effect.</p><h2 id="SpringSupport-MoreInformation">More Information</h2><p>Also check out the following blogs for information about using Spring JMS with ActiveMQ:</p><ul><li><a shape="rect" class="external-link" href="http://codedependents.com/2010/03/04/synchronous-request-response-with-activemq-and-spring/" rel="nofollow">Synchronous Request Response with ActiveMQ and Spr
ing</a></li><li><a shape="rect" class="external-link" href="http://bsnyderblog.blogspot.com/2010/02/using-spring-jmstemplate-to-send-jms.html" rel="nofollow">Using Spring to Send JMS Messages</a></li><li><a shape="rect" class="external-link" href="http://bsnyderblog.blogspot.com/2010/02/using-spring-to-receive-jms-messages.html" rel="nofollow">Using Spring to Receive JMS Messages</a></li><li><a shape="rect" class="external-link" href="http://bsnyderblog.blogspot.com/2010/05/tuning-jms-message-consumption-in.html" rel="nofollow">Tuning JMS Message Consumption In Spring</a></li></ul></div>
</td>
<td valign="top">
<div class="navigation">