I'm trying to implement a simple streaming pipeline:
Get list of users from a remote REST endpoint, spliting the list into individual messages
For each user I have to enrich it with information from a SQL parametric table (departments), e.g.:
Initial message (User 1)
id:1
departmentId: 1
parentDepartmentId: 23
Departments
Department 1
id: 1
name: Dep1
Department 2
id: 23
name: Dep23
Enriched User 1
id:1
departmentId: 1
departmentName: Dep1
parentDepartmentId: 23
parentDepartmentName: Dep23
Route context:
<routeContext id="route1" xmlns="http://camel.apache.org/schema/spring">
<route id="route1">
<from id="_from1" uri="timer:mytimer"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="Content-Type">
<constant>application/json</constant>
</setHeader>
<setBody>
<simple>{ "new": "true" }</simple>
</setBody>
<to id="_apiCall1" uri="https4://myapi/v1/users/search"/>
<split streaming="true">
<simple>${body}</simple>
<to uri="direct:processNewUser"/>
</split>
</route>
<route id="processNewUser">
<from uri="direct:processNewUser"/>
<enrich strategyRef="myAggregationStrategy">
<simple>sql:select * from departments"</simple>
</enrich>
</route>
</routeContext>
I need to get the whole departments table to be able to enrich the user information but I want to avoid doing so for every message.
Is there a way to store the content of the sql query and reuse it during the enrichment phase?