Spring Integration DSL - CharacterStreamWritingMessageHandle



我正在为基本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。希望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上打开一个问题。

相关内容

  • 没有找到相关文章

最新更新