I use Spring Cloud Sleuth integrated with Spring AMQP to enable traceId when publishing messages.
Sleuth automatically adds TracingMessagePostProcessor into RabbitTemplate.beforePublishPostProcessor to add trace headers to outgoing Rabbit messages.
I have a scenario: I have a batch of objects and want to publish them, like this:
List<Object> listObj = getData(...);
for (Object o : listObj) {
rabbitTemplate.convertAndSend(exchange, routingKey, o);
}
When I consume messages, all messages have same traceId. I don't want this.
How can I create just a rabbitTemplate bean without TracingMessagePostProcessor? Or how to make every message I publish/consume have a different traceId?
I already have read the Spring Cloud Sleuth docs. I can use the config...
spring.sleuth.messaging.rabbit.enabled=false
...to disable this feature, but I just want to disable it for a specified rabbitTemplate bean.