camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MichaelS <mihaistefanescu...@gmail.com>
Subject How to send a message to multiple endpoints in one transaction?
Date Mon, 31 Dec 2012 13:19:25 GMT
Hi,

I am trying to send the same message to multiple endpoints in one
transaction. That means i what the transaction to rollback if any error is
encountered and one of the endpoints doesn't receive the message, resulting
in the fact that the message is sent to the deadLetterQueue and in the fact
that none of the endpoints actually receive the message.

I use validateMessageProcessor to simulate an exception.
My route is: 
   errorHandler(deadLetterChannel("activemq:dead"));
        onException(Exception.class)
                .maximumRedeliveries(0)
                .handled(true);
                
        from("activemq:jms/RoutingQueue")
                .transacted("PROPAGATION_REQUIRED")
                .to("activemq:jms/MihaiQueue")
                .to("activemq:jmsActive")
                                .process(validateMessageProcessor)
                .to("activemq:a");

The context is:
    <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="transacted" value="true"/>
        <property name="transactionManager" ref="transactionManager"/>
    </bean>
    
    <bean id="transactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
        <property name="connectionFactory" ref="activeMQConnectionFactory"/>
    </bean>   
    
    <bean id="activeMQConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://TEST:61616"/>
        <property name="redeliveryPolicy">
            <bean class="org.apache.activemq.RedeliveryPolicy">
                <property name="maximumRedeliveries" value="0"/>
            </bean>
        </property>
    </bean>  
    
    <bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <property name="transactionManager" ref="transactionManager"/>
        <property name="propagationBehaviorName"
value="PROPAGATION_REQUIRED"/>
    </bean>

My problem is the fact that the message still arrives in jms/MihaiQueue and
jmsActive, even though it arrives in deadLetterQueue too.
Since sending to "a" has failed i want the messages from jms/MihaiQueue and
jmsActive to be rolled back.

Do you have any suggestions as to what i am doing wrong?



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-send-a-message-to-multiple-endpoints-in-one-transaction-tp5724749.html
Sent from the Camel Development mailing list archive at Nabble.com.

Mime
View raw message