Home > front end >  Log message is not printing on console while making API request using Apache Camel
Log message is not printing on console while making API request using Apache Camel

Time:12-28

I'm having issues while printing log message on console. I just need to make API request. Can someone help me on this if I'm making any issues ?

@Service
public class SftpWatcherRoute extends RouteBuilder {

  @Override
  public void configure() {

    from("direct:postCall")
        .process(exchange -> exchange.getIn().getBody())
        .setHeader(Exchange.HTTP_METHOD, constant("POST"))
        .setHeader("Content-Type",constant("application/json"))
        .to("http://localhost:8080/api/v1/start")
        .process(exchange -> log.info("The response code is: {}", exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))).
        end();
  }
}

Here are the logs which the above code is printing. But, I don't see the log message which I want to print on console.

2021-12-27 12:51:50.099  INFO 82161 --- [           main] com.SftpFileWatcher             : Started SftpFileWatcher in 7.406 seconds (JVM running for 8.463)
2021-12-27 13:41:44.621  INFO 82161 --- [ionShutdownHook] o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 3.14.0 (camel-1) shutting down (timeout:45s)
2021-12-27 13:41:44.626  INFO 82161 --- [ionShutdownHook] o.a.c.impl.engine.AbstractCamelContext   : Routes stopped (total:1 stopped:1)
2021-12-27 13:41:44.626  INFO 82161 --- [ionShutdownHook] o.a.c.impl.engine.AbstractCamelContext   :     Stopped route2 (direct://postCall)
2021-12-27 13:41:44.628  INFO 82161 --- [ionShutdownHook] o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 3.14.0 (camel-1) shutdown in 7ms (uptime:49m54s)

CodePudding user response:

set the camel.springboot.main-run-controller=true property in your configuration. For example in application.properties.

CodePudding user response:

Something should send a message to "direct:postCall" to start this route. You could change it to "timer://foo?repeatCount=1" and it will start automatically (https://camel.apache.org/components/3.14.x/timer-component.html).

  • Related