javaapache-camel

Camel Java DSL - invoking routes from code


Suppose Camel has two independent routes, for example:

from("/route1").log({body})....<n routes>...to("**bean:someClassABC**");

from("/route2").log({body})....<n routes>...to("bean:someClassXYZ").end();

Is it possible to invoke Camel Route2 from this class SomeClassABC via HTTPResponse method httpResponse.sendRedirect("/route2")?


Solution

  • Yes. It is technically possible.

    If /route2 is a http endpoint - sendRedirect from the someClassABC process method would work

    However if it is just another route - then ProducerTemplate should be used for the redirection