Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于EventBus 发布订阅模式, 订阅端抛出异常时,期望发布端可以监听到异常 #124

Closed
yinboxie opened this issue Nov 26, 2019 · 2 comments
Labels
Bug 🐛 有虫,来捉虫 Fixed ✔️ bug已修复
Milestone

Comments

@yinboxie
Copy link

我查阅了关于 EventBus相关的源码, 在EventBusBase类,Run方法中,使用了 try catch,直接将 订阅端handle 抛出的异常给捕获了,但是并未重新抛出。 如下代码:
private void Run(IEventHandlerFactory factory, IEventHandler handler, Type eventType, IEventData eventData)
{
try
{
handler.Handle(eventData);
}
catch (Exception ex)
{
string msg = $"执行事件“{eventType.Name}”的处理器“{handler.GetType()}”时引发异常:{ex.Message}";
Logger.LogError(ex, msg);
}
}
但是在实际应用过程中,很多事件的处理,需要确保数据的一致性,如生产模块领料动作需要通知仓库模块做库存的更改,仓库模块订阅了领料通知,如果库存处理失败了,则需要保证生产领料动作都得回滚。
当然,也有些场景,订阅端抛出异常时,是不需要发布端监听。
还请考虑 EventBus功能,增加此项新功能~~ 谢谢

@gmf520
Copy link
Member

gmf520 commented Nov 26, 2019

我觉得订阅端的异常应该由订阅端自己内部消化掉

@gmf520 gmf520 added Bug 🐛 有虫,来捉虫 Fixed ✔️ bug已修复 labels Mar 28, 2020
@gmf520 gmf520 added this to the v3.1.3 milestone Mar 28, 2020
@gmf520
Copy link
Member

gmf520 commented Mar 28, 2020

确认是一个bug,已修复

@gmf520 gmf520 closed this as completed Mar 28, 2020
@gmf520 gmf520 modified the milestones: v3.1.3, vNext Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 有虫,来捉虫 Fixed ✔️ bug已修复
Projects
None yet
Development

No branches or pull requests

2 participants