0

I have a scenario when I call one endpoint the another route should execute and return the result. Lets say I have an endpoint:

http://localhost:8080/api/customer

I am using the camel-jetty to start the above servlet endpoint, like:

from("jetty:http://localhost:8080/api/customer").to("controlbus:route?routeId=route2&action=start");

When I do GET request on this endpoint it will trigger another route defined as below:

from("paho://Properties").to("jsonata://some path").routeId("route2").noAutoStratup().log("Data : ${body}");

I tried to use camel-controlbus but it is not working.

How can I achieve this scenario? Can somebody please help me in this regard?

mdanish98
  • 65
  • 8
  • I recommend using the [Direct component](https://camel.apache.org/components/3.20.x/direct-component.html). `from(...).to(direct("myRouteName"));`, `from(direct("myRouteName"))...`. – Turing85 Jan 14 '23 at 12:25
  • I tried but the datasource i.e. paho retrieves data using "from" only, how could I define the paho endpoint in direct ? i.e. from(rest).to(direct:datasource); from(direct:datasource).to(..); As I am confused here. I also checked the provided link by you and it doesn't give information using direct with routeName. – mdanish98 Jan 14 '23 at 12:38
  • `direct` is a separate endpoint. We'd need to restructure the application. `paho` reads from MQTT and "does things". To restructure, we would separate-out what has to be done in both routes (i.e. the http-route and the mqtt-route) in a `direct` route – Turing85 Jan 14 '23 at 12:42
  • Thanks for the response :) As I am new in camel and still learning, could you please give an example of what you are saying? Thanks in advance – mdanish98 Jan 14 '23 at 12:45
  • 1
    [This tutorial over at `tutorialspoint.com`](https://www.tutorialspoint.com/apache_camel/apache_camel_quick_guide.htm) has some examples. I have no examples I can share at hand. – Turing85 Jan 14 '23 at 12:50

0 Answers0