Eventbus 和 Google Pub/SUb 之间的区别

Different between Eventbus and Google Pub/SUb

仅供参考,我知道有人问这个问题 here

但我有一个具体的问题。

  1. 它们有什么区别?
  2. 我可以将 EventBusGoogle Pub/Sub 一起使用吗?

1.它们有什么不同?

正如我们在 Guava EventBus 的 documentation 上看到的,它用于在应用程序内分发 java 事件。

It is designed exclusively to replace traditional Java in-process event distribution using explicit registration. It is not a general-purpose publish-subscribe system...

Cloud Pub/Sub 一个通用的发布订阅,具有多种 use cases.

文档说:

This supports an "enterprise event bus" and event-driven application design patterns.

但它与 Guava 的做法不同。

2。我可以将 Eventbus 与 Google Pub/Sub 一起使用吗?

考虑到开发,我可以说你可以使用Pub/Sub进行你的应用程序内部通信。但这将与 Guavas 所做和工作的不同。