Spring 集成 DSL - CharacterStreamWritingMessageHandler

Spring Integration DSL - CharacterStreamWritingMessageHandler

我正在为基本 amqp 示例 (https://github.com/spring-projects/spring-integration-samples/blob/master/basic/amqp/src/main/resources/META-INF/spring/integration/spring-integration-context.xml) 在 DSL 中编写示例代码

@Bean
public IntegrationFlow receiveGreetingFromGreetingQueueToConsole(ConnectionFactory connectionFactory) {

    return IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, "greeting.queue"))
            .log()
            .<String,String>transform(m -> "Received " + m)
            .handle(CharacterStreamWritingMessageHandler.stdout())
            .get();

}

如何在

上应用 setShouldAppendNewLine 布尔值
.handle(CharacterStreamWritingMessageHandler.stdout())

我不想将处理程序声明为 bean 只是为了设置此 属性。希望标准输出为此接受一个参数。

不一定是豆子...

@Bean
public IntegrationFlow receiveGreetingFromGreetingQueueToConsole(ConnectionFactory connectionFactory) {

    CharacterStreamWritingMessageHandler stdout = CharacterStreamWritingMessageHandler.stdout();
    stdout.setShouldAppendNewLine(true);
    return IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, "greeting.queue"))
            .log()
            .<String,String>transform(m -> "Received " + m)
            .handle(stdout)
            .get();

}

但是,我同意流利的 API 对 DSL 的使用会很好;请在 GitHub.

上打开一个问题