Hi,
I am using fuse ESB 4.3.0-fuse-01-00 (including Camel 2.4.0 and ActiveMQ 5.4.0).
I have created a transacted route :
from(sourceUri_)
.errorHandler(noErrorHandler())
.transacted("PROPAGATION_MANDATORY")
.policy(getTracePolicy())
.policy(getErrorReportingPolicy())
.process(eventProcessor_)
.recipientList(header(TARGET_HEADER));
Here the Spring part :
<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="pooledConnectionFactory" />
</bean>
<bean id="PROPAGATION_MANDATORY" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="propagationBehaviorName" value="PROPAGATION_MANDATORY" />
</bean>
My Source is an activemq queue.
In my processor i send a new message using the ProducerTemplate to another queue.
As i am using persistence (JDBC), i have logged the different requests.
And I have the following result (the 2 transactions are in the same session, but not the select):
execute <unnamed>: SELECT ID, PRIORITY FROM ACTIVEMQ_MSGS WHERE MSGID_PROD=$1 AND MSGID_SEQ=$2 AND CONTAINER=$3
execute S_1: BEGIN
execute <unnamed>: DELETE FROM ACTIVEMQ_MSGS WHERE ID=$1
execute S_2: COMMIT
execute S_1: BEGIN
execute <unnamed>: INSERT INTO ACTIVEMQ_MSGS(ID, MSGID_PROD, MSGID_SEQ, CONTAINER, EXPIRATION, PRIORITY, MSG) VALUES ($1, $2, $3, $4, $5, $6, $7)
execute <unnamed>: INSERT INTO ACTIVEMQ_MSGS(ID, MSGID_PROD, MSGID_SEQ, CONTAINER, EXPIRATION, PRIORITY, MSG) VALUES ($1, $2, $3, $4, $5, $6, $7)
execute S_2: COMMIT
I was expecting only one transaction to delete the processed message and insert the two "new" messages.
Am i wrong or have i forgotten a step in my transaction mechanism ?
What happened in this case if it crashes between the two requests ?
Thanks for answers.