英文:
Is Firestore event listener onEvent been called in sequence?
问题
我使用Firestore的EventListener<QuerySnapshot>
接口,我实现了它的onEvent
方法,并通过snapshot.getDocumentChanges
处理其更改。这些更改包括ADD
,MODIFIED
和REMOVE
。
有一件事对我不太清楚,就是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?
专注分享java语言的经验与见解,让所有开发者获益!
评论