3

I have this route:

from("timer://test?repeatCount=1").routeId("newRoute")
    .streamCaching()
    .process(exchange -> exchange.getIn()
        .setBody(exchange.getIn()
            .getBody()))
    .marshal()
    .json(JsonLibrary.Jackson)
    .setHeader(Exchange.HTTP_METHOD, constant("GET"))
    .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
    .to("http://localhost:8080/getAllUsers")
    .log(LoggingLevel.INFO, "This is my body: ${body}")
    .to("activemq:queue://new-queue");

When it is in @override configure() it is working on app. startup. But what I want to do is to call (trigger) that route from Spring Boot RestController.

I have GET endpoint and I want when I call it, the route to do it stuff.

Bambus
  • 1,493
  • 1
  • 15
  • 32
  • 2
    as stated by the method name, #configure configures the route inside the camel context, it does not "trigger". if you want to send a message on that route you should use a producer template. http://camel.apache.org/producertemplate.html – verodigiorgio Mar 23 '19 at 17:06

1 Answers1

3

You can replace the 'from' clause with something like:

from("direct:runGetAllUsers")

then in your Spring Rest controller you can invoke the Camel route. There is an example in the Camel In Action 2 book with source here.

Steve Huston
  • 1,432
  • 13
  • 20