如何自动自动春季云绑定



我在 application.yml

中定义了 errornotification绑定
cloud:
  stream:
    bindings:
      error:
        destination: error
        binder: default
      notification:
        destination: notification
        binder: default

如何将这些豆子放在我的组件中?

我尝试了这种方法:

@Component
class MyComponent {
   @Autowired
   @Qualified("notification")
   MessageChannel notificationChannel;
}

但找不到notificationChanel

更新 cloud.stream.bindings.*仅允许配置通道。但不会创建它。

您是否确定您有@EnableBinding和适当的接口来声明@Input@Output

https://docs.spring.io/spring-cloud-stream/docs/chelsea.sr2/reference/htmlsingle/index.html#declaring_and_and_and_and_binding_channels

public interface Barista {
    @Input
    SubscribableChannel orders();
    @Output
    MessageChannel hotDrinks();
    @Output
    MessageChannel coldDrinks();
}
...
@EnableBinding(Barista.class)
public class CafeConfiguration {

最新更新