Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.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 如果DSL流以端点结束,是否有默认输出通道?_Spring Integration_Spring Integration Dsl - Fatal编程技术网

Spring integration 如果DSL流以端点结束,是否有默认输出通道?

Spring integration 如果DSL流以端点结束,是否有默认输出通道?,spring-integration,spring-integration-dsl,Spring Integration,Spring Integration Dsl,下面DSL流的代码中的最后一个元素是Service Activator(.handle方法)。 这里有我可以订阅的默认输出直接通道吗?如果我理解正确,输出通道必须存在 我知道我可以在末尾添加.channel(“name”),但问题是如果没有明确地编写该怎么办。 代码如下: @SpringBootApplication @IntegrationComponentScan public class QueueChannelResearch { @Bean public Integr

下面DSL流的代码中的最后一个元素是Service Activator(
.handle
方法)。 这里有我可以订阅的默认输出直接通道吗?如果我理解正确,输出通道必须存在

我知道我可以在末尾添加
.channel(“name”)
,但问题是如果没有明确地编写该怎么办。 代码如下:

@SpringBootApplication
@IntegrationComponentScan
public class QueueChannelResearch {

    @Bean
    public IntegrationFlow lambdaFlow() {
        return f -> f.channel(c -> c.queue(50))
            .handle(System.out::println);
    }

    public static void main(String[] args) {
        ConfigurableApplicationContext ctx = SpringApplication.run(QueueChannelResearch.class, args);

        MessageChannel inputChannel = ctx.getBean("lambdaFlow.input", MessageChannel.class);

        for (int i = 0; i < 1000; i++) {
            inputChannel.send(MessageBuilder.withPayload("w" + i)
                .build());
        }

        ctx.close();

    }

不,那样不行

请记住,集成流是一个过滤管道体系结构,当前步骤的结果将被发送到下一个步骤。由于您使用
.handle(System.out::println)
println()
方法调用没有输出,因此不会返回任何内容来生成要发送到下一个通道(如果有)的消息。因此,流在这里停止。
void
返回类型或
null
返回值是service activator停止流的信号。在XML配置中考虑您的<代码>句柄(System .out::PrtLnn)< /C>作为<代码> <代码>。< /P> 是:没有任何默认频道,除非您事先通过
replyChannel
标题定义一个频道。但是,您的服务方法必须返回有价值的东西

ServiceActivator的输出是可选的,这就是为什么我们没有为出站通道适配器引入额外的操作符

关于
QueueChannel
的问题最好在单独的SO线程中处理。没有默认轮询器,除非您将其声明为
PollerMetadata.default\u poller
。你可以用一些图书馆来为你保管那个

 return f -> f.channel(c -> c.queue(50));
       //         .handle(System.out::println);