Camel Restlet - Context Path Ambiquity

I have Spring Boot Camel application where rest apis are exposed using camel-restlet

Sample route

@Component
public class AppRoute extends RouteBuilder{
    public void configure(CamelContext context){
       from("restlet:employee?restletMethods=GET").log("${body}");
    }
}

The App runs perfect ( spring-boot:run ). but am unable to locate under which path the API is exposed. Log has no information.

Every API i hit returns 404. Log shows the route has been started. Under which path is it running. And how do I change it?

Note: Please dont suggest any XML based configuration. Anything that I can put under @Configuration would be perfect

I would go with the Rest DSL which is supported by the camel-restlet component like this

restConfiguration().component("restlet").port(8080);

rest("/rest")
   .get("employee")
   .route().log("${body}")
   .endRest();

And this route will listen to the following url http://localhost:8080/rest/employee

EDIT: I guess you could do something like without using the Rest DSL

    String host = InetAddress.getLocalHost().getHostName();
    from("restlet:http://" + host + contextPath + "/employee?restletMethods=GET").log("${body}")

The port and context path are configurable with the following properties

camel.component.restlet.port=8686
server.servlet.context-path=/my-path

The context path can be injected in the routeBuilder with

@Value("${server.servlet.context-path}")
private String contextPath;

Camel Restlet - Context Path Ambiquity, Camel Restlet - Context Path Ambiquity. I have Spring Boot Camel application where rest apis are exposed using camel-restlet. Sample route. Leading context-path the REST services will be using. This can be used when using components such as SERVLET where the deployed web application is deployed using a context-path. Or for components such as camel-jetty or camel-netty-http that includes a HTTP server. apiContextPath-A leading API context-path the REST API services will be using.

According to the documentation, the format of the URI in a restlet endpoint definition should be the following:

restlet:restletUrl[?options]

Where restletUrl should have the following format:

protocol://hostname[:port][/resourcePattern]

So in your case you could define the URI in the following way:

from("restlet:http://localhost/employee?restletMethods=GET")

This should make the endpoint available under the following URL:

http://localhost/employee

Which you can test e.g. in a web browser.

REST DSL Component, ` contextPath. -. Leading context-path the REST services will be using. This can be used when using components  camel.component.restlet.enabled. Enable restlet component. true. Boolean. camel.component.restlet.enabled-converters. A list of converters to enable as full class name or simple class name. All the converters automatically registered are enabled if empty or null. List. camel.component.restlet.header-filter-strategy

Use the first of the three configuration methods described here: https://restlet.com/open-source/documentation/javadocs/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html

You should be able to customize it using the Component: https://restlet.com/open-source/documentation/javadocs/2.0/jee/api/org/restlet/Component.html?is-external=true

See in particular setServers() methods (or XML equivalent) to change the hostname and port.

Rest DSL - Apache Camel, Notice that in the REST service we route directly to a Camel endpoint using the to​() restConfiguration bindingMode = "auto" component = "restlet" port = "8080" / Sets a leading context-path the REST services will be using. The Camel Rest component to use for the REST transport, such as restlet, spark-rest. If no component has been explicit configured, then Camel will lookup if there is a Camel component that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry. If either one is found, then that is being used.

Keep requested host to endpoint with Apache Camel - rest - php, Camel Restlet - Context Path Ambiquity. I have Spring Boot Camel application where rest apis are exposed using camel-restlet Sample route #Component  The camel-servlet-starter library binds automatically all the rest endpoints under the /camel/* context path. The following table summarizes the additional configuration properties available in the camel-servlet-starter library. The automatic mapping of the Camel servlet can also be disabled.

Apache Camel Component Reference Red Hat JBoss Fuse 6.1 , Restlet, restlet:RestletUrl[?Options], camel-restlet, Component for consuming and If the path is start with "/", http producer will try to find the relative path based on on route start up will be thrown as this would introduce an ambiguity in name  View this message in context: http://old.nabble.com/camel-restlet-1-endpoint-for-any-path-without-list-uris-tp28049159p28049159.html Sent from the Camel - Users

Apache Camel 2.19 Released - What's New, The Apache Camel 2.19 release brings improvements to Spring Boot, Java, such as camel-servlet where you can easily setup the context-path from the application.properties file. based components in Camel such as restlet, http4, and undertow. <extension> just to avoid ambiguity in the file name. The jpa component enables you to store and retrieve Java objects from persistent storage using EJB 3’s Java Persistence Architecture (JPA), which is a standard interface layer that wraps Object/Relational Mapping (ORM) products such as OpenJPA, Hibernate, TopLink, and so on.

Comments
  • I already made a choice. I cant change it now. reslet gives me a better control
  • Yeah I know, I have been to the same situation with Rest DSL and camel-servlet. Its more powerful if you use the bare component, but harder to configure See my edits for a second option
  • This is an elementery way. I cannot hard code hostnam and port name in all the API There should be a way to register the url context globally. A configuration may be