Versions:
I want to add Sleuth to a pre-exisitng project that now makes use of ActiveMQ, previosuly it was jusing JMS. When I do, values from the ActiceMQ message get blocked/removed and (one being "filename" which is the key value for S2 requests). Other JMS values still seem to come through OK.
I need to understand why the non-JMS values are getting blocked/removed (I cannot find any information on what would be causing that to happen) to prevent the errors.
I know I can disbale Sleuth for JMS with spring.sleuth.messaging.jms.enabled=true
but moving forwards I'd like to be able to trace the ActiveMQ/JMS code, so that workaround isn't particularly attractive.
As this is pre-exiting code, I'd also like to avoid having to re-write it if at all possible.
Has anyone gotten SPring Cloud Sleuth to work with ActiveMQ/JMS and can maybe point out where things are going wrong?
Edit:
Based on the initial response from Marcin, we found that the following version compile & execute, although significant problems do remain:
Without Sleuth
Log message ("filename", "CamelAwsS3Etag" etc present):
2021-08-16 10:10:37.889 INFO [MyApp,,] 28775 --- [umer[taskQueue]] taskQueueConsumer: ***HEADERS IN***: {CamelAwsS3ETag=39d029a87fa4c6aaee5f1de643d9f3f6, Content-Type=application/json, filename=_bl001/group0/_bl001-group0-1629104686042.zip, JMSCorrelationID=null, JMSCorrelationIDAsBytes=null, JMSDeliveryMode=2, JMSDestination=queue://taskQueue, JMSExpiration=0, JMSMessageID=ID:server-44053-1629104652998-1:3:1:1:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=null, JMSTimestamp=1629104686350, JMSType=null, JMSXGroupID=_bl001-group0, JMSXGroupSeq=0, JMSXUserID=null}
With Sleuth
Log message ("filename", "CamelAwsS3Etag" etc are missing):
2021-08-16 10:24:33.821 INFO [MyApp,,] 31553 --- [umer[taskQueue]] taskQueueConsumer: ***HEADERS IN***: {JMSCorrelationID=null, JMSCorrelationIDAsBytes=null, JMSDeliveryMode=2, JMSDestination=queue://taskQueue, JMSExpiration=0, JMSMessageID=ID:server-42561-1629105658959-1:3:1:1:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=null, JMSTimestamp=1629105675306, JMSType=null, JMSXGroupID=_bl000-group1, JMSXGroupSeq=0, JMSXUserID=null}
Sample Java code
@Component
public class MyAppCoreRouter extends RouteBuilder {
/* Other code */
@Override
public void configure() {
from("activemq:queue:taskQueue?concurrentConsumers=" + taskNumberOfConcurrentConsumers)
.log("***HEADERS IN***: ${headers}")
.routeId("taskQueueConsumer")
.threads(taskNumberOfConcurrentConsumers)
.pollEnrich().simple("aws-s3://myapp-task?amazonS3Client=#amazonS3Client&fileName=${header.filename}&operation=getObject")
.choice()
.when(header(S3Constants.KEY).endsWith(".zip"))
.to("file://" + taskLocalUnCompressedEndpoint + "?fileName=${header.CamelAwsS3ETag}/${header.CamelAwsS3Key}")
.process(exchange -> {
String camelAwsS3ETag = exchange.getIn().getHeader("CamelAwsS3ETag", String.class);
String camelAwsS3Key = exchange.getIn().getHeader("CamelAwsS3Key", String.class);
File uniqueDir = new File(taskLocalUnCompressedEndpoint, camelAwsS3ETag);
File taskZip = new File(uniqueDir, camelAwsS3Key);
new ZipFile(taskZip).extractAll(uniqueDir.getAbsolutePath());
})
.setHeader("resourceDirectory", simple(taskLocalUnCompressedEndpoint + "/${header.CamelAwsS3ETag}")).setHeader("schedule.time", simple("${date:now}"))
.removeHeader("CamelAwsS3Headers")
.log(LoggingLevel.DEBUG, "Processing batch job ${headers}")
.to("spring-batch:importMyAppRecordJob")
.endChoice()
.otherwise()
.log(LoggingLevel.WARN, "Unexpected file type, filtering file name ${header.CamelAwsS3Key} ")
.end();
/* Other code */
}
}
You're using wrong versions of Boot, Cloud and Sleuth. To use Sleuth 3.0.x you need to use Cloud 2020.0.x and Boot 2.4.x or 2.5.x.