You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by tbarnes <th...@intuit.com> on 2010/06/09 23:59:14 UTC

Transactional JMS Route Constantly Opening/Closing Connections

Transactional JMS Route Opening/Closing Connections

I would like to setup a route that utilizes transactional delivery of JMS
messages to avoid dropping messages in the event of server failures. To do
this I have utilized the Camel Transaction documentation to set up
transactional routes (Camel version 2.2).  This Camel Engine is running
within ActiveMQ (5.3.1) to do some lightweight processing/routing/mediation
of messages.  Here is the camel configuration:

<beans
   xmlns="http://www.springframework.org/schema/beans"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
   http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
  
  	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="jmstx:example.A"/>
            <to uri="jmstx:example.B"/>
        </route>
    </camelContext>


	<!-- JmsComponent Transactional Delivery of JMS Messages -->
	
        <bean id="jmstx"
class="org.apache.camel.component.jms.JmsComponent">
          <property name="configuration" ref="jmsConfig" />
        </bean>

        <bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
           <property name="connectionFactory" ref="jmsConnectionFactory"/>
           <property name="transactionManager" ref="jmsTransactionManager"/>
           <property name="transacted" value="true"/>
        </bean>

        <bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
           <property name="connectionFactory" ref="jmsConnectionFactory" />
        </bean>	
	
	<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
		<property name="brokerURL"
value="vm://localhost?create=false&amp;waitForStart=10000" />
		<property name="userName" value="${activemq.username}" />
		<property name="password" value="${activemq.password}" />
	</bean>
</beans>

Before I even send any messages through this route I receive the following
opening/closing of connetions (logging at Debug level):


2010-04-21 13:38:18,387 | DEBUG | Setting up new connection id:
ID:tbarneswin7-60077-1271882288129-2:8, address: vm://localhost#14 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#15
2010-04-21 13:38:18,387 | DEBUG | localhost adding consumer:
ID:tbarneswin7-60077-1271882288129-2:8:-1:1 for destination:
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic |
org.apache.activemq.broker.region.AbstractRegion | VMTransport:
vm://localhost#15
2010-04-21 13:38:19,392 | DEBUG | ID:tbarneswin7-60077-1271882288129-2:8:1
Transaction Commit :null | org.apache.activemq.ActiveMQSession |
DefaultMessageListenerContainer-1
2010-04-21 13:38:19,393 | DEBUG | localhost removing consumer:
ID:tbarneswin7-60077-1271882288129-2:8:-1:1 for destination:
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic |
org.apache.activemq.broker.region.AbstractRegion | VMTransport:
vm://localhost#15
2010-04-21 13:38:19,393 | DEBUG | remove connection id:
ID:tbarneswin7-60077-1271882288129-2:8 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#15
2010-04-21 13:38:19,395 | DEBUG | Stopping connection: vm://localhost#14 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:19,395 | DEBUG | Stopped transport: vm://localhost#14 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:19,408 | DEBUG | Setting up new connection id:
ID:tbarneswin7-60077-1271882288129-2:9, address: vm://localhost#16 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#17
2010-04-21 13:38:19,409 | DEBUG | Connection Stopped: vm://localhost#14 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:19,409 | DEBUG | localhost adding consumer:
ID:tbarneswin7-60077-1271882288129-2:9:-1:1 for destination:
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic |
org.apache.activemq.broker.region.AbstractRegion | VMTransport:
vm://localhost#17
2010-04-21 13:38:20,411 | DEBUG | ID:tbarneswin7-60077-1271882288129-2:9:1
Transaction Commit :null | org.apache.activemq.ActiveMQSession |
DefaultMessageListenerContainer-1
2010-04-21 13:38:20,411 | DEBUG | localhost removing consumer:
ID:tbarneswin7-60077-1271882288129-2:9:-1:1 for destination:
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic |
org.apache.activemq.broker.region.AbstractRegion | VMTransport:
vm://localhost#17
2010-04-21 13:38:20,412 | DEBUG | remove connection id:
ID:tbarneswin7-60077-1271882288129-2:9 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#17
2010-04-21 13:38:20,413 | DEBUG | Stopping connection: vm://localhost#16 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:20,414 | DEBUG | Stopped transport: vm://localhost#16 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:20,415 | DEBUG | Connection Stopped: vm://localhost#16 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:20,416 | DEBUG | Setting up new connection id:
ID:tbarneswin7-60077-1271882288129-2:10, address: vm://localhost#18 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#19

Is there some mis-configuration that I am doing that causes these JMS
connections to be opened/closed constantly?  Should I utilize another method
to create these Camel Routes?  Any suggestions or recommendations are
appreciated.

Here is the actual camel file used to isolate the problem: 
http://old.nabble.com/file/p28836324/camel.xml camel.xml 
-- 
View this message in context: http://old.nabble.com/Transactional-JMS-Route-Constantly-Opening-Closing-Connections-tp28836324p28836324.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: AW: Transactional JMS Route Constantly Opening/Closing Connections

Posted by Charles Moulliard <cm...@gmail.com>.
Hi,

You must declare the following bean if you want to use a connection pool factory

    <bean id="pooledConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactoryBean">
        <property name="maxConnections" value="8" />
        <property name="maximumActive" value="500" />
        <property name="transactionManager" ref="transactionManager" />
        <property name="connectionFactory" ref="activemqConnectionFactory" />
        <property name="resourceName" value="activemq.default" />
    </bean>

Next, you can reference it from your ActiveMQComponent bean

KR,

Charles Moulliard

Senior Enterprise Architect (J2EE, .NET, SOA)
Apache Camel/ServiceMix Committer

*******************************************************************
- Blog : http://cmoulliard.blogspot.com
- Twitter : http://twitter.com/cmoulliard
- Linkedlin : http://www.linkedin.com/in/charlesmoulliard



On Thu, Jun 10, 2010 at 8:00 PM, tbarnes <th...@intuit.com> wrote:
>
> Christoph,
>
> Thanks I just tried the ActiveMQ component instead of the JMS Component:
>
> <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>   <property name="connectionFactory" ref="jmsConnectionFactory"/>
>   <property name="transacted" value="true"/>
>   <property name="transactionManager" ref="jmsTransactionManager"/>
> </bean>
>
> and I get the same result.  Next I will try the PoolingConnectionFactory to
> see if the constant connection/disconnections are minimized.
>
> Thanks for your suggestions.
>
> Regards,
> Thomas
>
>
>
> Meise, Christoph wrote:
>>
>> Maybe this helps: http://camel.apache.org/jms.html#JMS-Notes, especially
>> the pooling of connections which is recommended when using Springs
>> JmsTemplate.
>> Regards,
>> Christoph
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Transactional-JMS-Route-Constantly-Opening-Closing-Connections-tp28836324p28846528.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: AW: Transactional JMS Route Constantly Opening/Closing Connections

Posted by tbarnes <th...@intuit.com>.
Christoph,

Thanks I just tried the ActiveMQ component instead of the JMS Component:

<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
   <property name="connectionFactory" ref="jmsConnectionFactory"/>
   <property name="transacted" value="true"/>
   <property name="transactionManager" ref="jmsTransactionManager"/>
</bean>

and I get the same result.  Next I will try the PoolingConnectionFactory to
see if the constant connection/disconnections are minimized.

Thanks for your suggestions.

Regards,
Thomas



Meise, Christoph wrote:
> 
> Maybe this helps: http://camel.apache.org/jms.html#JMS-Notes, especially
> the pooling of connections which is recommended when using Springs
> JmsTemplate.
> Regards,
> Christoph
> 
> 

-- 
View this message in context: http://old.nabble.com/Transactional-JMS-Route-Constantly-Opening-Closing-Connections-tp28836324p28846528.html
Sent from the Camel - Users mailing list archive at Nabble.com.


AW: Transactional JMS Route Constantly Opening/Closing Connections

Posted by "Meise, Christoph" <ch...@immobilienscout24.de>.
Maybe this helps: http://camel.apache.org/jms.html#JMS-Notes, especially the pooling of connections which is recommended when using Springs JmsTemplate.
Regards,
Christoph

-----Ursprüngliche Nachricht-----
Von: tbarnes [mailto:thomas_barnes@intuit.com] 
Gesendet: Mittwoch, 9. Juni 2010 23:59
An: users@camel.apache.org
Betreff: Transactional JMS Route Constantly Opening/Closing Connections


Transactional JMS Route Opening/Closing Connections

I would like to setup a route that utilizes transactional delivery of JMS
messages to avoid dropping messages in the event of server failures. To do
this I have utilized the Camel Transaction documentation to set up
transactional routes (Camel version 2.2).  This Camel Engine is running
within ActiveMQ (5.3.1) to do some lightweight processing/routing/mediation
of messages.  Here is the camel configuration:

<beans
   xmlns="http://www.springframework.org/schema/beans"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
   http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
  
  	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="jmstx:example.A"/>
            <to uri="jmstx:example.B"/>
        </route>
    </camelContext>


	<!-- JmsComponent Transactional Delivery of JMS Messages -->
	
        <bean id="jmstx"
class="org.apache.camel.component.jms.JmsComponent">
          <property name="configuration" ref="jmsConfig" />
        </bean>

        <bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
           <property name="connectionFactory" ref="jmsConnectionFactory"/>
           <property name="transactionManager" ref="jmsTransactionManager"/>
           <property name="transacted" value="true"/>
        </bean>

        <bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
           <property name="connectionFactory" ref="jmsConnectionFactory" />
        </bean>	
	
	<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
		<property name="brokerURL"
value="vm://localhost?create=false&amp;waitForStart=10000" />
		<property name="userName" value="${activemq.username}" />
		<property name="password" value="${activemq.password}" />
	</bean>
</beans>

Before I even send any messages through this route I receive the following
opening/closing of connetions (logging at Debug level):


2010-04-21 13:38:18,387 | DEBUG | Setting up new connection id:
ID:tbarneswin7-60077-1271882288129-2:8, address: vm://localhost#14 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#15
2010-04-21 13:38:18,387 | DEBUG | localhost adding consumer:
ID:tbarneswin7-60077-1271882288129-2:8:-1:1 for destination:
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic |
org.apache.activemq.broker.region.AbstractRegion | VMTransport:
vm://localhost#15
2010-04-21 13:38:19,392 | DEBUG | ID:tbarneswin7-60077-1271882288129-2:8:1
Transaction Commit :null | org.apache.activemq.ActiveMQSession |
DefaultMessageListenerContainer-1
2010-04-21 13:38:19,393 | DEBUG | localhost removing consumer:
ID:tbarneswin7-60077-1271882288129-2:8:-1:1 for destination:
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic |
org.apache.activemq.broker.region.AbstractRegion | VMTransport:
vm://localhost#15
2010-04-21 13:38:19,393 | DEBUG | remove connection id:
ID:tbarneswin7-60077-1271882288129-2:8 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#15
2010-04-21 13:38:19,395 | DEBUG | Stopping connection: vm://localhost#14 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:19,395 | DEBUG | Stopped transport: vm://localhost#14 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:19,408 | DEBUG | Setting up new connection id:
ID:tbarneswin7-60077-1271882288129-2:9, address: vm://localhost#16 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#17
2010-04-21 13:38:19,409 | DEBUG | Connection Stopped: vm://localhost#14 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:19,409 | DEBUG | localhost adding consumer:
ID:tbarneswin7-60077-1271882288129-2:9:-1:1 for destination:
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic |
org.apache.activemq.broker.region.AbstractRegion | VMTransport:
vm://localhost#17
2010-04-21 13:38:20,411 | DEBUG | ID:tbarneswin7-60077-1271882288129-2:9:1
Transaction Commit :null | org.apache.activemq.ActiveMQSession |
DefaultMessageListenerContainer-1
2010-04-21 13:38:20,411 | DEBUG | localhost removing consumer:
ID:tbarneswin7-60077-1271882288129-2:9:-1:1 for destination:
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic |
org.apache.activemq.broker.region.AbstractRegion | VMTransport:
vm://localhost#17
2010-04-21 13:38:20,412 | DEBUG | remove connection id:
ID:tbarneswin7-60077-1271882288129-2:9 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#17
2010-04-21 13:38:20,413 | DEBUG | Stopping connection: vm://localhost#16 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:20,414 | DEBUG | Stopped transport: vm://localhost#16 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:20,415 | DEBUG | Connection Stopped: vm://localhost#16 |
org.apache.activemq.broker.TransportConnection | ActiveMQ Task
2010-04-21 13:38:20,416 | DEBUG | Setting up new connection id:
ID:tbarneswin7-60077-1271882288129-2:10, address: vm://localhost#18 |
org.apache.activemq.broker.TransportConnection | VMTransport:
vm://localhost#19

Is there some mis-configuration that I am doing that causes these JMS
connections to be opened/closed constantly?  Should I utilize another method
to create these Camel Routes?  Any suggestions or recommendations are
appreciated.

Here is the actual camel file used to isolate the problem: 
http://old.nabble.com/file/p28836324/camel.xml camel.xml 
-- 
View this message in context: http://old.nabble.com/Transactional-JMS-Route-Constantly-Opening-Closing-Connections-tp28836324p28836324.html
Sent from the Camel - Users mailing list archive at Nabble.com.