Solace Spring cloud stream and opentracing

Hi @marc
I have finally found some time and could continue working on this project. I didn’t manage to intercept InboundXMLMessageListener.handleMessage because the JCSMPInboundChannelAdapter.buildListener method is private. But I did this:

@Configuration
@EnableConfigurationProperties({SolaceExtendedBindingProperties.class})
@ComponentScan(excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = {SolaceMessageChannelBinderConfiguration.class})})
public class SolaceMessageChannelBinderTracingConfiguration {

    private static final Logger LOG = LoggerFactory.getLogger(SolaceMessageChannelBinderTracingConfiguration.class);

    private final SpringJCSMPFactory springJCSMPFactory;
    private final SolaceExtendedBindingProperties solaceExtendedBindingProperties;

    private JCSMPSession jcsmpSession;

    public SolaceMessageChannelBinderTracingConfiguration(
            final SpringJCSMPFactory springJCSMPFactory,
            final SolaceExtendedBindingProperties solaceExtendedBindingProperties) {
        this.springJCSMPFactory = springJCSMPFactory;
        this.solaceExtendedBindingProperties = solaceExtendedBindingProperties;
    }

    @PostConstruct
    private void initSession() throws JCSMPException {
        jcsmpSession = springJCSMPFactory.createSession();
        LOG.info(String.format("Connecting JCSMP session %s", jcsmpSession.getSessionName()));
        jcsmpSession.connect();
    }

    @Bean
    SolaceMessageChannelBinder solaceMessageChannelBinder(
            final SolaceOutboundMessageTracingAspect outputMessageTracingAspect,
            final SolaceInboundMessageTracingAspect inboundMessageTracingAspect) {
        final SolaceMessageChannelBinder binder = new SolaceMessageChannelBinder(jcsmpSession, provisioningProvider()) {
            @Override
            protected MessageHandler createProducerMessageHandler(ProducerDestination destination, ExtendedProducerProperties producerProperties,
                    MessageChannel errorChannel) {
                final MessageHandler messageHandler = super.createProducerMessageHandler(destination, producerProperties, errorChannel);
                return ProxyUtil.createProxy(messageHandler, outputMessageTracingAspect);
            }

            @Override
            protected MessageProducer createConsumerEndpoint(ConsumerDestination destination, String group, ExtendedConsumerProperties properties) {
                final MessageProducer messageProducer = super.createConsumerEndpoint(destination, group, properties);
                return ProxyUtil.createProxy(messageProducer, inboundMessageTracingAspect);
            }
        };
        binder.setExtendedBindingProperties(solaceExtendedBindingProperties);
        return binder;
    }

    @Bean
    SolaceQueueProvisioner provisioningProvider() {
        return new SolaceQueueProvisioner(jcsmpSession);
    }
}

With the outboundMessageTracingAspect I intercept_ org.springframework.messaging.MessageHandler.handleMessage_ to decorate the message with tracing information.
With the inboundMessageTracingAspect I intercept org.springframework.integration.core.MessageProducer.setOutputChannel to adapt the MessageChannel. The adapter extracts the tracing information out of the message before delegating to the real messageChannel.
But now I have to dive into the opentracing topic to get the tracing implementation right.