'cannot read from RabbitMQ topic with camel's consumer template

I cannot receive a message on the topic B

rabbitmq:q.cmdb.config.insight.b?routingKey=insightConfigB&exchangeType=topic&autoDelete=false

By settings some camel properties like not deleting the topic when the consumer has successfully consumed the topic's data. My purpose is to trigger a microservice with two manners (from rabbitmq or cxfrs), with rabbitmq is Okay I receive the body but with cxfrs, I'm getting an empty body, even if I have created a template consumer that reads from a second topic B that contains the same message as topic A.

The topic B:

rabbitmq:q.cmdb.config.insight.b?routingKey=insightConfigB&exchangeType=topic&autoDelete=false

Below is my first route that calls the route in the second microservices with rabbitmq:

from("cxfrs:bean:rsServerOrchestrator")
                .routeId("orchestrator-route-ws")
                .onException(Exception.class)
                .handled(true)
                .log(LoggingLevel.ERROR, "Technical Error : ${exception.stacktrace}")
                .bean(iUtilsService, "buildErrorMessage")
                .end()
                .choice()
                .when(simple("${header.operationName} == 'schema'"))
                .to("direct:configurationInsightRoute")
                .id("configurationInsightRoute")
                .to(ExchangePattern.InOnly,"{{rabbitmq.endpoint.routingKeyA}}")
                .to(ExchangePattern.InOnly,"{{rabbitmq.endpoint.routingKeyB}}")

My properties:

rabbitmq.endpoint.routingKeyA=rabbitmq:q.cmdb.config.insight.a?routingKey=insightConfigA&exchangeType=topic&autoDelete=false
rabbitmq.endpoint.routingKeyB=rabbitmq:q.cmdb.config.insight.b?routingKey=insightConfigB&exchangeType=topic&autoDelete=false

My camel routes in second microservice:

from("cxfrs:bean:rsServerTenable")
                .routeId("tenable-route-ws")
                .onException(Exception.class)
                .handled(true)
                .log(LoggingLevel.ERROR, "Technical Error : ${exception.stacktrace}")
                .bean(iUtilsService, "buildErrorMessage")
                .end()
                .choice()
                .when(simple("${header.operationName} == 'synchro'"))
                .setHeader("isFromQueue", () -> false)
                .log(LoggingLevel.INFO, "Synchronisation des os tenable")
                .to("direct:tenableOsChoice");

        from("{{rabbitmq.endpoint.routingKeyA}}")
                .routeId("tenable-route-rabbitmq")
                .onException(Exception.class)
                .handled(true)
                .log(LoggingLevel.ERROR, "Technical Error : ${exception.stacktrace}")
                .bean(iUtilsService, "buildErrorMessage")
                .end()
                .setHeader("isFromQueue", () -> true)
                .to("direct:tenableOsChoice");

        from("direct:tenableOsChoice")
                .routeId("tenable-os-choice")
                .onException(Exception.class)
                .handled(true)
                .log(LoggingLevel.ERROR, "Technical Error : ${exception.stacktrace}")
                .bean(iUtilsService, "buildErrorMessage")
                .end()
                .choice()
                .when(simple("${header.isFromQueue} == 'false'"))
                .process((exchange -> {
                    ConsumerTemplate template = getCamelContext().createConsumerTemplate();
                    exchange.getIn().setBody(template.receiveBody("{{rabbitmq.endpoint.routingKeyB}}", 2000, String.class));
                }))
                .otherwise()
                .setBody(body())
                .end()
                .setHeader("insightConfigBody", body())
                .to("direct:tenableOs");

        from("direct:tenableOs")
                .routeId("tenable-os")
                .log(LoggingLevel.INFO, "insightConfig: ${header.insightConfigBody}");

When calling the route above with id "tenable-route-ws" by cxfrs, the consumer template in route with id "tenable-os-choice" consumes nothing, I have expected to get the body from queue rabbitmq.endpoint.routingKeyB.

Thanks a lot for your help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source