[英]Spring Cloud Stream Apps - Passing information between steps
Can anyone suggest me ways to pass metadata between steps of SCDF pipe? 谁能建议我在SCDF管道步骤之间传递元数据的方法? Here are some of the use cases I'm trying to address:
这是我要解决的一些用例:
I'm hoping that there is a way of sending such details in the rabbit or kafka message headers. 我希望有一种在Rabbit或kafka消息头中发送此类详细信息的方法。
You can/should certainly utilize Message headers. 您可以/应该肯定利用消息头。 Remember you control he return value of the handler method.
记住要控制他返回处理程序方法的值。 If your handler method returns POJO, then the framework will create a Message from it copying certain headers etc. However, in your case if you want to control everything that goes into the Message (including headers) all you need is to define handler method that returns Message (see below):
如果您的处理程序方法返回POJO,则该框架将通过复制某些标头等从其创建消息。但是,在您的情况下,如果您想控制消息中包含的所有内容(包括标头),则只需定义处理程序方法即可返回消息(见下文):
@StreamListener(..)
@SendTo(..)
public Message<?> handle(String str) {
. . .
return MessageBuilder.withPayload(..).setHeader(..).setHeader(..).build();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.