Search code examples
restspring-bootapache-camelspring-camel

Apache Camel REST - not connecting


I'm trying to get Apache Camel's REST DSL working but it's not connecting for me.

I've got a RouteBuilder that's being called:

@Override
public void configure() {
restConfiguration().component("servlet")
      .contextPath("/")
      .enableCORS(true)
      .dataFormatProperty("prettyPrint", "true")
      .apiContextPath("/api-doc")
      .apiProperty("api.version", buildVersion)
      .apiProperty("cors", "true")
      .bindingMode(RestBindingMode.json);

rest("/say/hello")
      .get().route().transform().constant("Hello World");
}

but then the routes don't actually work.

This is inside a Spring Boot app that has other REST endpoints defined via JAX-RS but this is an integration package that I want to be able to keep separate. The weird thing is that this WAS working a few months ago before I had to work on other things, but now, coming back to it, I can't even get this simple endpoint working.

I've got Camel in my Maven pom.xml and everything seems to be starting correctly, but nothing happens when I hit http:://localhost:9071/say/hello, I just get the standard Tomcat 404 page.

Any thoughts on what I'm missing?


Solution

  • According to this: http://www.baeldung.com/apache-camel-spring-boot

    As of Camel’s version 2.19, this configuration has been dropped as the CamelServlet is by default set to “/camel”.

    so /camel/say/hello is the correct URL and it works for me. Still looking at how to customize this.

    EDIT:

    Here's how to customize this under Spring Boot. You add a property to application.properties like this:

    camel.component.servlet.mapping.contextPath=/*