如何从轴突禁用特定事件处理程序?
我们在代码中配置了一些事件处理程序。但是,我想从轴突禁用特定的事件处理程序。
请注意 - 我可以使用 @Profile 或 @Conditional 参数来执行此操作。但是,我很想知道是否有类似 EventConfig 中的配置的方法可以从处理中排除特定的事件处理程序。
请参考下面的代码。
事件源配置
public class AxonConfig {
public void configureProcessorDefault(EventProcessingConfigurer processingConfigurer) {
processingConfigurer.usingSubscribingEventProcessors();
}
}
事件处理程序
@ProcessingGroup("this")
class ThisEventHandler {
// your event handlers here...
}
@ProcessingGroup("that")
class ThatEventHandler {
// your event handlers here...
}
@ProcessingGroup("other")
class OtherEventHandler {
// your event handlers here...
}```
We have a few event handlers configured in the code. But, I'd like to disable a particular event handler from axon.
Please note - I can do this using @Profile or @Conditional parameter. But, I am interested to know if there is any way like config at EventConfig to exclude the particular event handler from processing.
Please refer below code.
Event Source Config
public class AxonConfig {
public void configureProcessorDefault(EventProcessingConfigurer processingConfigurer) {
processingConfigurer.usingSubscribingEventProcessors();
}
}
Event handlers
@ProcessingGroup("this")
class ThisEventHandler {
// your event handlers here...
}
@ProcessingGroup("that")
class ThatEventHandler {
// your event handlers here...
}
@ProcessingGroup("other")
class OtherEventHandler {
// your event handlers here...
}```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为
EventProcessingConfigurer
的结果而构造的EventProcessingConfiguration
提供了一种检索事件处理器实例的方法。此外,任何EventProcessor
实现都有start()
和shutDown()
方法。因此,您可以停止您想要停止的事件处理器。
以下代码将为您完成此任务:
作为附注,我会警告仅使用
SubscribingEventProcessor
。在事件处理器实现中,它在性能、分发和错误处理方面提供的灵活性最少。我宁愿尝试使用 PooledStreamingEventProcessor 来代替。The
EventProcessingConfiguration
that's constructed as a result of theEventProcessingConfigurer
provides a means to retrieve your Event Processor instances. Furthermore, anyEventProcessor
implementation has astart()
andshutDown()
method.You can thus stop the Event Processors that you want to stop.
The following piece of code would get that done for you:
As a side note, I would warn against only using the
SubscribingEventProcessor
. Of the Event Processor implementations, it provides the least amount of flexibility when it comes to performance, distribution and error handling. I'd much rather try using thePooledStreamingEventProcessor
instead.