I want to reuse transformation steps defined by blueprint DSL in different camel routes but couldn't find out how to achieve this.
Let's give an example here:
<camelContext id="jms-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="inputAqTest8">
<from id="_fromAqTest8" uri="aqTest8:queue:QUELOGENTRY"/>
<!-- some complicated transformation here -->
<to id="_to1" uri="umChannel:topic:Input"/>
</route>
<route id="inputAqTest12">
<from id="_fromAqTest12" uri="aqTest12:queue:QUEPOSTDATA"/>
<!-- some complicated transformation here -->
<to id="_to2" uri="umChannel:topic:Input"/>
</route>
</camelContext>
I already optimized this by moving the transformation and the delivery to an own route connected by the direct component.
<camelContext id="jms-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="inputAqTest8">
<from id="_fromAqTest8" uri="aqTest8:queue:QUELOGENTRY"/>
<to id="_to1" uri="direct:process"/>
</route>
<route id="inputAqTest12">
<from id="_fromAqTest12" uri="aqTest12:queue:QUEPOSTDATA"/>
<to id="_to2" uri="direct:process"/>
</route>
<route id="process">
<from id="_from1" uri="direct:process"/>
<!-- some complicated transformation here -->
<to id="_to" uri="umChannel:topic:Input"/>
</route>
</camelContext>
This perfectly reuses the transformation logic. But since direct synchronizes the 'calls' the routes are no longer independent. Also, I now have only one producer slowing down since no parallel delivery of the transformed messages can happen (this is also the reason why I didn't want to merge all into a single route).
So how can I get the best of both approaches - reuse the definition of the transformation and keep the routes independent? Thanks in advance for your ideas.
That is not correct about direct, its just like a java method call so you can call the route concurrently from each route, its just using the calling thread.
So what you have done with separating that transformer logic into a route and call it using direct is a good solution.