camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Monica_G <mgranb...@gmail.com>
Subject Aggregator strategy and killing the process
Date Sat, 24 Oct 2009 00:10:29 GMT

Hi,

I'm wondering if it is possible to recover from the case where someone
Cntrl-Cs a process that uses an aggregator.

For example, I have an aggregator with a batchTimout set to 5 minutes.  If
someone Cntrl-C's the program at 2 minutes, the messages that have been
consumed up to that point are lost as they have been consumed off the queue,
but not sent onto the destination.

I'm looking into using transacted() but haven't had any luck so far.  

Here is what I am doing in my RouteBuilder:

from(inputEndpoint)
            .policy(jmsTransactionPolicy)
            .transacted()
            .unmarshal().xstream()
            .aggregate(header("my_id"), new MyListAggregationStrategy())
            .batchTimeout(batchTimeout)
            .batchSize(0) 
            .marshal().xstream().convertBodyTo(String.class)
            .to(destinationEndpoint);


my xml config looks like the following:

  <bean id="myBroker" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="jndiConnectionFactory"/>
    <property name="destinationResolver" ref="jmsDestinationResolver"/>
    <property name="transacted" value="true"/>
    <property name="transactionManager" ref="jmsTransactionManager"/>
    
  </bean>

  <bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
    <property name="connectionFactory" ref="jndiConnectionFactory"/>
  </bean>

  <bean id="jmsTransactionPolicy"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
    <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
    <property name="transactionManager" ref="jmsTransactionManager"/>
  </bean>

<bean id="jndiConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate">
      <ref bean="jndiTemplate"/>
    </property>
    <property name="jndiName">
      <value>XXXX_CONNECTION_FACTORY</value>
    </property>
  </bean>

<bean id="jndiTemplate"
        class="org.springframework.jndi.JndiTemplate"
        factory-bean="jndiTemplateFactory"
        factory-method="createJndiTemplate"/>

Thanks,

Monica
-- 
View this message in context: http://www.nabble.com/Aggregator-strategy-and-killing-the-process-tp26034906p26034906.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message