Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在Java中使用vert.x, 我想通过在mod.json中声明“包含”或更好地将ebean模块设置为系统模块,在标准模块(事件循环)中使用工作模块(EBean ORM)。
这会阻止事件循环,所以我应该只使用事件总线吗?
如果您的模块有阻塞代码(使用阻塞 API 或进行大量计算),则不应在事件循环中使用它。黄金法则:永远不要阻塞事件循环。否则您的应用程序将无法响应。
即使您的模块中的代码是非阻塞的,我也会尝试使用标准模块方式:您可以更轻松地使用不同的语言重用它,并且如果您决定将来更改内部实现细节,您不会破坏您的用户代码就像通过事件总线获得 JSON 接口一样简单。