【发布时间】:2018-01-02 08:10:09
【问题描述】:
我正在尝试使用 Spring Cloud Stream 在 kafka 上发送和接收消息。此示例使用使用时间戳作为消息的简单示例。当我在InboundChannelAdapter docs 上遇到这个阻止程序时,我正试图更进一步地进入一个真实世界的应用程序:
“带有@InboundChannelAdapter注解的方法不能接受任何参数”
我试图这样使用它:
@InboundChannelAdapter(value = ChannelManager.OUTPUT)
public EventCreated createCustomerEvent(String customerId, String thingId) {
return new EventCreated(customerId, thingId);
}
我缺少什么用途?我想当你想创建一个事件时,你有一些数据要用于该事件,所以你通常会通过参数传递这些数据。但是“用@InboundChannelAdapter 注释的方法不能接受任何参数”。那么你应该如何使用它呢?
我知道 @InboundChannelAdapter 来自 spring-integration,它是 spring-cloud-stream 的扩展,因此 spring-integration 可能有不同的上下文,这在其中是有意义的。但这对我来说似乎不直观(就像使用 _INBOUND_ChannelAdapter 作为输出/生产者/源一样)
【问题讨论】:
标签: spring apache-kafka spring-integration spring-cloud spring-cloud-stream