Hi,
I work in a project that's using Camel since 2.0-M1 (Spring version is
2.5.6)
Since then, we've migrated all big batch business logic to the
Camel-ActiveMQ framework, but since last big migration, with some million
message processing per day, we've noticed that sometimes database data
inserted in a queue A is not yet commited, so can't be readed/updated on
next queue B if message is processed immediately it's been sent by the
SendProcessor of the ToDefinition.

I have tested the same behaviour on Camel 2.6.0 + Spring 3.0.5 (need Java
1.5) and it's the same, so any idea if it's something wrong about
Transaction Interception strategy?

Simple example that produces the "error":


RouteBuilder config:

@Override
        protected void doConfigure() throws Exception 
        {
                errorHandler(errorHandlerBuilder());
                
                
from("non-xa://TransactionTestInsertQueue?maxConcurrentConsumers=10")
                .policy(getPropagationPolicy())
                .process(new SetQueueErrorProcessor("errorTransactionTest"))
                .process(new TransactionTestInsertProcessor())
                .to("non-xa://TransactionTestSelectQueue");
                
                
from("non-xa://TransactionTestSelectQueue?maxConcurrentConsumers=10")
                .policy(getPropagationPolicy())
                .process(new TransactionTestSelectProcessor());
                
                from("non-xa://errorTransactionTest?maxConcurrentConsumers=1")
                .policy(getPropagationPolicy())
                .process(new NoActionErrorProcessor());
        }

TransactionTestInsertProcessor.java inserts a registry in database and sets
info inserted into a Metadata
TransactionTestSelectProcessor.java selects the registry in database by id
of the incoming Metadata of the Exchange

Have extended the DataSourceTransactionManager to LOG transaction id opened,
commited or rollbacked, and to simulate a delay to reproduce the "select
before it's inserted" problem with a Thread.sleep.

Resulting LOG:

2011-10-17 12:42:46,194  INFO [DefaultMessageListenerContainer-1]
(MyDataSourceTransactionManager.java:17) - doBegin ee2a92
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2011-10-17 12:42:46,197 DEBUG [DefaultMessageListenerContainer-1]
(AbstractProcessor.java:47) - SetQueueErrorProcessor : Recibido mensaje :
VOID
2011-10-17 12:42:46,219  INFO [DefaultMessageListenerContainer-1]
(AbstractProcessor.java:73) - Tiempo proceso: SetQueueErrorProcessor - 21
2011-10-17 12:42:46,227 DEBUG [DefaultMessageListenerContainer-1]
(AbstractProcessor.java:47) - TransactionTestInsertProcessor : Recibido
mensaje : VOID
2011-10-17 12:42:46,302  INFO [DefaultMessageListenerContainer-1]
(TransactionTestInsertProcessor.java:27) - Insert ID=16131843
2011-10-17 12:42:46,353  INFO [DefaultMessageListenerContainer-1]
(AbstractProcessor.java:73) - Tiempo proceso: TransactionTestInsertProcessor
- 125
2011-10-17 12:42:46,371  INFO [DefaultMessageListenerContainer-1]
(MyDataSourceTransactionManager.java:64) - sleep 10000 : ee2a92
2011-10-17 12:42:46,377  INFO [DefaultMessageListenerContainer-1]
(MyDataSourceTransactionManager.java:17) - doBegin 15fccae
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2011-10-17 12:42:46,377 DEBUG [DefaultMessageListenerContainer-1]
(AbstractProcessor.java:47) - TransactionTestSelectProcessor : Recibido
mensaje : <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:MonitorMetadata xmlns:ns2="http://es.indra/bsf/common/MonitorMetadata";>
    <IdProceso>16131843</IdProceso>
    <Tipo>TransactionTest</Tipo>
    <Fecha>2011-10-17T12:42:46.228+01:00</Fecha>
    <Informacion>For test purpose only</Informacion>
</ns2:MonitorMetadata>

2011-10-17 12:42:46,378 DEBUG [DefaultMessageListenerContainer-1]
(IOConverter.java:57) - Convirtiendo String - MonitorMetadata
2011-10-17 12:42:46,390 ERROR [DefaultMessageListenerContainer-1]
(TransactionTestSelectProcessor.java:27) - Error : No encontrado PQ con
ID=16131843
2011-10-17 12:42:46,391  INFO [DefaultMessageListenerContainer-1]
(AbstractProcessor.java:73) - Tiempo proceso: TransactionTestSelectProcessor
- 13
2011-10-17 12:42:46,391  INFO [DefaultMessageListenerContainer-1]
(MyDataSourceTransactionManager.java:64) - sleep 10000 : 15fccae
2011-10-17 12:42:56,372  INFO [DefaultMessageListenerContainer-1]
(MyDataSourceTransactionManager.java:23) - doCommit ee2a92
2011-10-17 12:42:56,393  INFO [DefaultMessageListenerContainer-1]
(MyDataSourceTransactionManager.java:23) - doCommit 15fccae


Any idea will be tested.
Thanks.


--
View this message in context: 
http://camel.465427.n5.nabble.com/Transaction-behaviour-after-ToDefinition-tp4909694p4909694.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to