0

I need to write a Camel route that would send a file to a web service. Before sending the file to the endpoint, I have to query a database for some information and send the file to the endpoint along with additional information. I would also have to move the file to another directory after the entire route has completed. I was able to create the individual parts of the route independently. I wanted to know how I could do this in a single route.

user6641655
  • 523
  • 2
  • 8
  • 13

1 Answers1

0

It's your design decision how to do that. You can have your individual parts as sub-routes (that is my preferable way).

It makes route more functional structured and at least more readable. Then you can pass your message(file) to them one after another or in parallel by using multicast component.

in XML DSL it will look like:

<route id="main-route">
    <from uri="..." />
    <!-- DB processing --> 
    <to uri="direct:db-route-endpoint"/>
    <multicast parallelProcessing="false">
    <!-- No parallel processing: file will be stored after Web Service call completed
         or for parallel parallelProcessing="true" -->"
        <to uri="...web service endpoint... "/>
        <to uri="direct:store-file-endpoint"/>
    </multicast>
</route>

<route id="db-route">
    <from uri="direct:db-route-endpoint" />
    ... DB processing ...
</route>

<route id="store-file-route">
    <from uri="direct:store-file-endpoint" />
    ... save file to another directory ...
</route>
Vadim
  • 4,027
  • 2
  • 10
  • 26