运行时访问主题信息

自 2.9 版本起,您可以通过注入提供的 DestinationTopicContainer bean 访问运行时的主题链信息。 此接口提供查找链中下一个主题或为该主题配置的 DLT 的方法,以及诸如主题名称、延迟和类型等有用属性。spring-doc.cadn.net.cn

作为一个实际使用场景示例,你可以使用此类信息,使控制台应用程序在导致处理失败的原因(例如bug/状态不一致)得到解决后,将记录从DLT重新发送到链中的第一个重试主题。spring-doc.cadn.net.cn

The DestinationTopic provided by the DestinationTopicContainer#getNextDestinationTopicFor() method corresponds to the next topic registered in the chain for the input topic. The actual topic the message will be forwarded to may differ due to different factors such as exception classification, number of attempts or single-topic fixed-delay strategies. Use the DestinationTopicResolver interface if you need to weigh in these factors.