kent steinwall
kent steinwall

Reputation: 15

How to pass parameters into a method in Apache Camel using spring boot

rest()
    .get("/{id}")
    .produces(MediaType.APPLICATION_JSON_VALUE)
    .route()
    .setBody(() - > orderService.viewOrder())
    .endRest();

I am using apache 2.24.0 version. how to pass id parameter to viewOrder method

Upvotes: 0

Views: 497

Answers (1)

Luca Burgazzoli
Luca Burgazzoli

Reputation: 1236

The parameters are mapped to message headers with the same name, so in this case you can get the value of the id like:

rest()
  .get("/{id}")
  .produces(MediaType.APPLICATION_JSON_VALUE)
  .route()
  .process(e -> {
     String id = e.getIn().getHeader("id", String.class);
     ...
  });

Upvotes: 1

Related Questions