camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oliT <oliver.tr...@gmx.at>
Subject Camel keeps adding and removing Consumers when using DefaultMessageListenerContainer
Date Fri, 09 Nov 2007 15:23:50 GMT

hi there,

Setup:
Spring 2.1 
Camel 1.2 
ActiveMQ 5 the latest snapshot

SampleConfiguration:
this is just the minimal configuration to trigger the issue:
  <bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:6666" />
      </bean>
    </property>
  </bean>
  
  <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="jmsFactory" />
    <property name="camelContext" ref="camel" />
    <property name="consumerType" value="Default"></property>
  </bean>

  <bean id="queueTest" factory-bean="camelEndpointFactory"
factory-method="getEndpoint">
    <constructor-arg value="jms:queueTest" />
  </bean>

  <!-- CAMEL ROUTES -->

  <bean id="routesType" class="Routes">
    <property name="routes">
      <list>
        <bean class="com.xtradesoft.tg.olt.messaging.camel.Route">
          <property name="input" ref="queueTest" />
          <property name="output">
            <list>
              <ref bean="testBean" />
            </list>
          </property>
        </bean>
      </list>
    </property>
  </bean>

  <bean id="testBean" class="TestBean"></bean>

My Problem:
when i start is minimal sample configuration it keeps creating new consumer
threads on a second basis. So each second i get a new thread. I think this
is a great overhead since the resources are created and destroyed each time. 
I tried setting the consumerType to ServerSessionPool(like in the sample
below) and add a ServerSessionFactory to the JmsComponent but i get this
exception: "Session pool provided an invalid session type: class
org.apache.activemq.pool.PooledSession"

<bean id="jms"
  class="org.apache.camel.component.jms.JmsComponent">
  <property name="connectionFactory" ref="jmsFactory" 
  <property name="camelContext" ref="camel" /> 
  <property name="consumerType" value="ServerSessionPool"></property>
  <property name="serverSessionFactory">
    <bean
class="org.springframework.jms.listener.serversession.SimpleServerSessionFactory"
/>
  </property>
</bean>

I looked into the sourceCode and what i found is that camel, depending on
the consumerType, creates a Simple, Default oder
ServerSessionMessageListenerContainer.
I cannot use simple since i need the transaction capability of at least the
default container. However i am not satisfied with its behavior. If i run 10
components each using a camel route then 10 consumers per second are created
and destroyed. 
It seems that setting "maxMessagesPerTask" for the jms component will slow
the creation down since he will then create a new thread after X receive
calls (as defined in maxMessagesPerTask).
But the principle Problem stays the same. 
I looked into the sourcecode of the DefaultContainer and it seems to me that
this is the desired behaiviour, and maybe this is needed to give it
transactional capabilities??.

Maybe i am walking in the wrong direction here.. . I tried to use the
Server-Container but i cannot get it running. It seems the
serversessionfactory returns a pooledsession wich itself wraps the ActiveMQ
Session. I could write a wrapper for that myself to "extract" the session,
but i dont feel that is the way it was ment to be.

What are you guy's doing about that? Do you simply live with it or is there
some way around it?

thanks in advance!

oliver



-- 
View this message in context: http://www.nabble.com/Camel-keeps-adding-and-removing-Consumers-when-using-DefaultMessageListenerContainer-tf4778316s22882.html#a13669076
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message