【发布时间】:2018-07-06 03:50:33
【问题描述】:
我一直在阅读 spring-cloud-stream 文档,特别是error handling:
@StreamListener(Sink.INPUT) // destination name 'input.myGroup'
public void handle(Person value) {
throw new RuntimeException("BOOM!");
}
@ServiceActivator(inputChannel = Processor.INPUT + ".myGroup.errors") //channel name 'input.myGroup.errors'
public void error(Message<?> message) {
System.out.println("Handling ERROR: " + message);
}
关于文档的内容,当您想要捕获错误时,您可能想要使用@ServiceActivator。这没有关联的外部目的地。
@StreamListener 注解的使用专门用于 定义桥接内部渠道和外部渠道的绑定 目的地。鉴于目标特定的错误通道确实 没有关联的外部目的地,这样的通道是 Spring Integration (SI) 的特权。这意味着处理程序 对于此类目的地,必须使用 SI 处理程序之一定义 注释(即@ServiceActivator、@Transformer 等)。
我还关注了关于error channel creation 的整个帖子,它确认拥有@ServiceActivator 注释不会创建外部目标来传播错误。
我有一个用例,外部侦听器进程将使用发布到特定 Kafka 错误主题的错误。基于此,我有以下问题,
-
@ServiceActivator的具体用途是什么,或者这个特定注释提供的功能是什么? - 将错误传播到外部目标的好方法是什么? (例如,一个 Kafka 主题)。
- 是否将错误发布到外部目标以便以后以良好的模式使用?
【问题讨论】:
标签: spring spring-integration spring-cloud spring-cloud-stream spring-cloud-dataflow