I'm trying to configure a microservice with Sleuth and ActiveMQ. When starting a request I can properly see appName, traceId and spanId in logs of producer, but after dequeuing the message in listener I find only appName, without traceId and spanId. How can I get this fields filled?
Right now I'm working with spring.sleuth.messaging.jms.enabled=false to avoid this exception at startup:
My dependencies:
org.springframework.boot.spring-boot-starter-activemq 2.5.1
org.springframework.cloud.spring-cloud-sleuth 3.0.3
Thank you all!
My understanding is that the properties you're looking for are set on the JMS message when the message is sent and then retrieved from the message when it is consumed. Since you're setting spring.sleuth.messaging.jms.enabled=false
you're disabling this functionality. See the documentation which states:
We instrument the
JmsTemplate
so that tracing headers get injected into the message. We also support@JmsListener
annotated methods on the consumer side.To block this feature, set
spring.sleuth.messaging.jms.enabled
tofalse
.
You'll need to find an alternate solution for the connection factory problem if you want to use Sleuth with Spring JMS. If you're injecting org.apache.activemq.ActiveMQConnectionFactory
somewhere then you should almost certainly be using javax.jms.ConnectionFactory
instead. Using the concrete type is bad for portability and use-cases like this where wrapper implementations are used dynamically.