0
votes

I configured Camel REST with Spring Boot and enabled actuator/camelroutes as in this example: https://github.com/apache/camel/blob/master/examples/camel-example-spring-boot/src/main/resources/application.properties

Now i am able to get my route descriptions... the problem is they are showing as route1,route2 etc, and provide no description which makes it difficult to distinguish which route belongs to which REST endpoint, e.g.

{
    "id": "route2",
    "uptime": "3.172 seconds",
    "uptimeMillis": 3172,
    "properties": {
        "parent": "49889154",
        "rest": "true",
        "description": null,
        "id": "route2"
    },
    "status": "Started"
}

Question is how do I provide custom description and id to rest() routes?

My route is simple:

      rest("/hello")
            .description("/hello GET endpoint")
            .consumes("application/json").produces("text/html")
            .get("/").description("Hello World example").outType(String.class)
            .to("direct:hello")

and i tried adding .description after .rest("/bla") but it has no effect in the actuator/camelroutes

Ideally, i would like to get something like below:

 {
    "id": "route1",
    "description": "direct hello route returning simple string",
    "uptime": "3.173 seconds",
    "uptimeMillis": 3173,
    "properties": {
        "parent": "76af51d6",
        "rest": "false",
        "description": "direct hello route returning simple string",
        "id": "route1"
    },
    "status": "Started"
},
1

1 Answers

0
votes

You need to set id and description to route context, not to rest context.

For example this definition:

rest("/hello")
        .consumes("application/json").produces("text/html")
        .get("/").outType(String.class)
        .route().id("sayHi").description("This endpoint says Hi")
        .to("direct:hello");

from("direct:hello")
        .routeId("hello")
        .setBody(constant("Hi"));

Generates this actuator output:

[
  {
    "id": "hello",
    "uptime": "13.158 seconds",
    "uptimeMillis": 13158,
    "status": "Started"
  },
  {
    "id": "sayHi",
    "description": "This endpoint says Hi",
    "uptime": "13.145 seconds",
    "uptimeMillis": 13145,
    "status": "Started"
  }
]