Hi Charles

My route is pretty simple.

<route id="SubmitRoute">
                        <from uri="direct:Submit" />
                        <to uri="SaveProcessor" />
</route>

So what the SaveProcessor does is it takes hibernate DataObject from the
camel exchange that we want to save to the DB. Now say there are 3 different
threads sending 3 different DO objects (each has a unique primary key- an
UUID) to the saveProcessor. Now in the saveProcessor when I get the
DataObjects from the exchange I expect those to be same as what was
originally sent, but I see one DO is getting repeated (so the same primary
key is duplicated for couple of different threads) meaning i get only 2 ids
3rd one is lost. This behavior is causing hibernate exceptions as 2
different threads operate on same row in table in the same hibernate
session.This happens sporadically.

Let me give an example here

        @Autowired
        private CamelContext camelContext;
        
        @Test(enabled = true,invocationCount=3,threadPoolSize=3)
        public void testCamelContext(){
                Exchange exchange = new DefaultExchange(camelContext);
                System.out.println("thread id :" + 
Thread.currentThread().getId());
                exchange.setProperty(CamelConstants.ABC_DO, abcDO);//setting 
the DO to
save
                callSaveProcessor(exchange);//calling the saveProcessor this 
internally
calls the route.
        }

        private void callSaveProcessor (Exchange exchange) {
                AbcDO abc = 
exchange.getProperty(CamelConstants.ABC_DO,AbcDO.class);
                System.out.println("in getting back the 
property"+abc.getId());//you get
duplicate primary //keys  here. 
        }

Please let me know.




--
View this message in context: 
http://camel.465427.n5.nabble.com/problem-with-exchange-getProperty-in-multi-threaded-environment-tp5757354p5757368.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to