0
votes

My Apache camel project is starting to have a pretty good structure but I'm getting stuck because my routes inside my routeContext execute infinitely. All my routes use the SQL Component and I want all of my routes only to execute once.

What I am finding is that when I have two routes in my routeContext both routes only execute once but as soon as I add a third (no matter what route that third is), camel starts to execute all the routes infinitely. All of my routes lead to sql inserts so having the same route run more than once causes a duplicate key error.

I thought it might be an error in one of my routes but I've tried switching the order around etc and everytime I switch from two to three routes in my routeContext the problem comes up again. Tonight I also tried to separate the routes out into different route contexts but it didn't change anything. I also took out all error handlers to make sure it wasn't related to them.

I'm starting to think this is a bug with the sql component in Camel. What are everyone's thoughts? Should I switch to a different component (for example jdbc) ?

Here is what my xml files look like...

camel-context

<import resource="camel-routes.xml"/>
<import resource="database.xml"/>       

<camel:camelContext trace="true">   
  <camel:propertyPlaceholder location="classpath:sql.properties" id="placeholder"/>
  <camel:routeContextRef ref="sourceToStaging"/>
</camel:camelContext>

camel-routes

<routeContext id="sourceToStaging" xmlns="http://camel.apache.org/schema/spring">
<route id="processTypeOption-route">    
    <from uri="sourceSql:{{sql.selectTypeOption}}"/>
    <transacted/>           
    <to uri="targetSql:{{sql.insertTypeOptionOrig}}"/>                          
    <to uri="targetSql:{{sql.insertTypeOptionStg}}"/>                       
    <to uri="controlbus:route?routeId=processTypeOption-route&amp;action=stop&amp;async=true"/>
</route>

<route id="processProductSize-route">    
    <from uri="sourceSql:{{sql.selectProductSize}}"/>
    <transacted/>           
    <to uri="targetSql:{{sql.insertProductSizeOrig}}"/>                             

    <to uri="targetSql:{{sql.insertProductSizeStg}}"/>                     
    <to uri="controlbus:route?routeId=processProductSize-route&amp;action=stop&amp;async=true"/>
</route>                
<route id="processStatus-route">    
    <from uri="sourceSql:{{sql.selectStatus}}"/>
    <transacted/>           
    <to uri="targetSql:{{sql.insertStatusOrig}}"/>                              
    <to uri="targetSql:{{sql.insertStatusStg}}"/>                       
    <to uri="controlbus:route?routeId=processStatus-route&amp;action=stop&amp;async=true"/>
</route>                        
</routeContext> 

Can anyone please assist. Thks

1
Is there n e thing obviously wrong here or does this pattern seem okay?Richie
What Camel version do you use?Claus Ibsen
I use camel version 2.11.1Richie
I've updated the question to show some other stuff I tried to use to debug the issue. But still no luck. ThanksRichie

1 Answers

0
votes

I've had a similar situation. But thread executed infinitely while loading the camel context. Try removing the CamelHttp* from exchange header after hitting an endpoint.