Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration 错误';是单向的';MessageHandler';用于spring集成聚合器DSL_Spring Integration - Fatal编程技术网

Spring integration 错误';是单向的';MessageHandler';用于spring集成聚合器DSL

Spring integration 错误';是单向的';MessageHandler';用于spring集成聚合器DSL,spring-integration,Spring Integration,我正在尝试使用DSL测试spring集成的一些东西。到目前为止,这只是一个测试,流程很简单: 创建一些消息 并行处理(记录)它们 把它们聚合起来 记录聚合 除了聚合器外,它工作正常: @Bean public IntegrationFlow integrationFlow() { return IntegrationFlows .from(integerMessageSource(), c -> c.poller(Pollers.fixedRate(1,

我正在尝试使用DSL测试spring集成的一些东西。到目前为止,这只是一个测试,流程很简单:

  • 创建一些消息
  • 并行处理(记录)它们
  • 把它们聚合起来
  • 记录聚合
除了聚合器外,它工作正常:

@Bean
public IntegrationFlow integrationFlow() {
    return IntegrationFlows
            .from(integerMessageSource(), c -> c.poller(Pollers.fixedRate(1, TimeUnit.SECONDS)))
            .channel(MessageChannels.executor(Executors.newCachedThreadPool()))
            .handle((GenericHandler<Integer>) (payload, headers) -> {
                System.out.println("\t delaying message:" + payload + " on thread "
                        + Thread.currentThread().getName());
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    System.err.println(e.getMessage());
                }
                return payload;
            })
            .handle(this::logMessage)
            .aggregate(a ->
                    a.releaseStrategy(g -> g.size()>10)
                     .outputProcessor(g ->
                             g.getMessages()
                                     .stream()
                                     .map(e -> e.getPayload().toString())
                                     .collect(Collectors.joining(",")))

                     )
            .handle(this::logMessage)
            .get();

}
据我所知,它抱怨聚合器没有输出


完整的源代码可以在这里找到:

问题在于聚合器之前的
句柄()
-它不产生任何结果,因此没有要聚合的内容

        .handle(this::logMessage)
        .aggregate(a ->
大概
logMessage(Message)
具有
void
返回类型

如果要在聚合器之前登录,请使用
wireltap
,或更改
logMessage
以在登录后返回
消息

        .wireTap(sf -> sf.handle(this::logMessage))

谢谢,窃听成功了。我试图更改logMessage()以返回消息,但这并没有改变行为。由于版本
1.2
有一个
.log()
运算符正是用于此目的的。请阅读有关此事的博客帖子:
        .wireTap(sf -> sf.handle(this::logMessage))