Sulagna Roy
Sulagna Roy

Reputation: 11

Is it possible to call one RouteBuilder from another RouteBuilder in Camel

I have two different Processes. One read some csv file and store it in DB and other fetch the record from DB and calculate some value and store it in DB. I want to call the second process at the completion of the first. Is it possible to do this with the help of the camel.

Upvotes: 1

Views: 1138

Answers (2)

Alexey Yakunin
Alexey Yakunin

Reputation: 1771

You have many possibilities to connect one route to each other:

  • direct component.
  • vm component.
  • seda component.
  • activemq, jms components.
  • direct-vm component.

More information can be found here: https://camel.apache.org/components.html

  • direct, direct-vm - components for synchronous messaging.
  • seda, vm - components for asynchronous, in-memory messaging.
  • activemq, jms - components for asynchronous messaging through JMS.
  • direct-vm, vm - in-memory messaging, can be used, to connect routes deployed in different OSGI Bundles, for example.

Upvotes: 2

fiw
fiw

Reputation: 756

To 'call' another route when one route has finished you just send the exchange to that route with a .to() and the direct component.

from("file:/csv-drop/")
    .to(db:store)
    .to("direct:calculate-value-and-store")

in another route builder or the same route builder:

from("direct:calculate-value-and-store")
    .to(db:get)
    .process(new CalculateValueProcessor())
    .to(db:store)

This code above won't work but it gives you an idea of what using two routes looks like.

Upvotes: 2

Related Questions