in artemis-elasticsearch/src/main/java/org/acme/Routes.java [44:69]
public void configure() {
rest()
.post("/devices")
.to("direct:devices")
.get("/devices")
.produces("application/json")
.to("direct:getDevices");
from("direct:devices")
.routeId("direct-devices")
.to("paho:devices");
from("paho:devices")
.routeId("paho-devices")
.process(exchange -> {
String body = exchange.getMessage().getBody(String.class);
exchange.getMessage().setBody(Map.of("devices", body));
})
.marshal().json()
.to("elasticsearch-rest-client:docker-cluster?operation=INDEX_OR_UPDATE&indexName=devices");
from("direct:getDevices")
.routeId("get-devices")
.setHeader(ElasticSearchRestClientConstant.SEARCH_QUERY).constant("{\"query\":{\"match_all\":{}}}")
.to("elasticsearch-rest-client:docker-cluster?operation=SEARCH&indexName=devices");
}