Apache Camel JPA Thread Hung

329 views Asked by At

I have created one route using Java DSL which has JPA component to poll the records from DB periodically. it is working good. I hope each route has one worker thread. if DB is down or any N/W issue for minute, route is not working as expected. application is running.( it is not polling records from DB even after DB or N/W is up ). I think worker thread got hung and route is not working.

SimpleRegistry registry = new SimpleRegistry(); 
registry.put("datasource",myDataSourceObj);
CamelContext context = new DefaultCamelContext(registry); 
context.addRoutes(new myRouteBuilder()); 

from URI= "uri="jpa://br.rafaeltuelho.model.Customer?consumer.namedQuery=Customer.findAll&consumer.delay=30000&consumeDelete=true" 

please anybody help me to fix this issue. How to avoid this worker thread hung ? How to restart the worker thread once N/W or DB is up ?

1

There are 1 answers

0
Gnana On BEST ANSWER

After adding 2 params in JPA URI . it is working good after DB is up.

+ "&sharedEntityManager=true"
+ "&joinTransaction=false"

JPA component in camel cannot reconnect automatically to database