在软件工程(尤其是领域驱动设计 DDD)中,“domain event”指领域中已经发生且对业务有意义的事件,用来记录并传播“某件重要事情发生了”(例如:订单已支付、账户已冻结)。它常用于解耦系统模块、触发后续流程、实现异步处理等。
/doʊˈmeɪn ɪˈvɛnt/
The payment succeeded, so we published a domain event.
支付成功后,我们发布了一个领域事件。
After the order was confirmed, the system emitted a domain event that triggered inventory updates and sent a notification to the customer.
订单确认后,系统发出一个领域事件,触发库存更新并向客户发送通知。
“Domain”源自拉丁语 dominium(意为“所有权、统治范围”),后来引申为“领域、范围”;“Event”源自拉丁语 eventus(意为“发生的事、结果”)。合在一起在现代软件语境中表示“业务领域里发生的一件关键事情”。