【问题标题】:Spring Integration wiretap direct MessageChannel for TestingSpring Integration 窃听直接 MessageChannel 进行测试
【发布时间】:2018-06-14 06:29:06
【问题描述】:

我想对两个同样使用 Spring 集成流的 Spring Boot 应用程序进行集成测试。为了测试我的应用程序,我想检查通过myMessageChannel 发送的消息。它是在其中一个应用程序的 XML 流中定义的。

如何窃听我的直接消息通道并将消息重定向到 PollableChannel,以便我可以一一阅读它们? 我在网上找到的方法都不适合我。

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {App1.class, App2.class}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@TestPropertySource("classpath:integration.properties")
public class MyWireTapTest {

    @Autowired
    MessageChannel myMessageChannel;

    @Test
    public void test() {


        // This is basically what I want to do
        // But it does not work, since it is a direct channel
        myMessageChannel.recieve();

    }
}

【问题讨论】:

    标签: java spring spring-boot spring-integration spring-integration-dsl


    【解决方案1】:

    将其自动连接为AbstractMessageChannel 并使用

    myMessageChannel.addInterceptor(new WireTap(tapChannel));

    【讨论】:

      【解决方案2】:

      我写了一个示例演示如何做到这一点(通过 XML 配置):

      https://github.com/hakanozbay/spring-integration-testing

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-10-30
        • 2017-10-16
        • 1970-01-01
        • 2013-12-23
        • 1970-01-01
        • 1970-01-01
        • 2011-06-10
        相关资源
        最近更新 更多