Firestore事件监听器的onEvent方法是否按顺序调用?

huangapple 未分类评论46阅读模式
英文:

Is Firestore event listener onEvent been called in sequence?

问题

我使用Firestore的EventListener<QuerySnapshot>接口,我实现了它的onEvent方法,并通过snapshot.getDocumentChanges处理其更改。这些更改包括ADDMODIFIEDREMOVE

有一件事对我不太清楚,就是Firestore是否会从多线程调用我的onEvent(我正在使用Java API)?如果是这样的话,我可能会遇到麻烦。例如,我首先收到了ADD消息,同时它仍在处理ADD消息,然后又来了一条新的MODIFY消息,这样我就会遇到数据不一致的问题。

Firestore Java API是否以多线程方式执行,我是否需要处理多线程?

英文:

I use Firestore EventListener[QuerySnapshot] interface, which I implement its onEvent method, and process its changes by snapshot.getDocumentChanges. The changes are ADD, MODIFIED and REMOVE.

One thing that is not clear to me is, will Firestore call my onEvent from multi-thread (I'm using Java API)? If true then I might have trouble. For example I first got ADD message, while it is still processing the ADD message, a new message of MODIFY came, then I have data non-consistence problem.

Does Firestore Java API do it in a multi-thread fashion then I have to take care of the multi-threading?

huangapple
  • 本文由 发表于 2020年4月8日 20:02:19
  • 转载请务必保留本文链接:https://java.coder-hub.com/61100211.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定