首页 > 解决方案 > GlobalChannelInterceptor 传递模式数组

问题描述

我是 Spring Integration 4.3.13 并在配置 @GlobalChannelInterceptor 时尝试传递模式

这是示例

@Configuration
public class IntegrationConfig{

   @Bean
   @GlobalChannelInterceptor(patterns = "${spring.channel.interceptor.patterns:*}")

 public ChannelInterceptor channelInterceptor(){
    return new ChannelInterceptorImpl();
 }

}

属性文件具有以下值:

spring.channel.interceptor.patterns=*intchannel,*事件

我正在使用名称以这两个字符串结尾的直接频道

  1. 弹簧通道
  2. 注册活动

使用上面的配置,两个通道都应该配置拦截器,但它没有被配置。

标签: spring-integration

解决方案


目前不支持逗号分隔值。

我同意我们需要修复它,所以请随时就此事提出 JIRA,我们将从其他地方提交解决方案。

同时,您可以将其作为一种解决方法:

    @Bean
    public GlobalChannelInterceptorWrapper channelInterceptorWrapper(@Value("${spring.channel.interceptor.patterns:*}") String[] patterns) {
        GlobalChannelInterceptorWrapper globalChannelInterceptorWrapper = new GlobalChannelInterceptorWrapper(channelInterceptor());
        globalChannelInterceptorWrapper.setPatterns(patterns);
        return globalChannelInterceptorWrapper;
    }

推荐阅读