Working around the stomp workaround

without this workaround there is a problem with mutability of headers
with this change / workaround we're ensuring that the headers remain immutable.

We will fix this in Spring Framework 6; Spring Boot 3 in a much better way

fixes gh-1325
This commit is contained in:
Marcin Grzejszczak
2022-01-27 12:28:34 +01:00
parent fb8cb90957
commit 2f2ced8593

View File

@@ -38,9 +38,11 @@ import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ConfigurationCondition;
import org.springframework.core.Ordered;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.integration.channel.interceptor.GlobalChannelInterceptorWrapper;
import org.springframework.integration.config.GlobalChannelInterceptor;
import org.springframework.messaging.support.ImmutableMessageChannelInterceptor;
import org.springframework.messaging.support.MessageHeaderAccessor;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -86,6 +88,16 @@ public class TraceSpringIntegrationAutoConfiguration {
traceMessagePropagationGetter, remoteServiceNameMapper(properties), messageSpanCustomizer);
}
@Bean
GlobalChannelInterceptorWrapper afterSleuthImmutableMessageChannelInterceptor(
SleuthIntegrationMessagingProperties properties) {
GlobalChannelInterceptorWrapper interceptor = new GlobalChannelInterceptorWrapper(
new ImmutableMessageChannelInterceptor());
interceptor.setOrder(Ordered.LOWEST_PRECEDENCE);
interceptor.setPatterns(properties.getPatterns());
return interceptor;
}
static Function<String, String> remoteServiceNameMapper(SleuthMessagingProperties properties) {
return s -> {
if (!StringUtils.hasText(s)) {