Is it possible to lose events when using long-polling to retrieve real time notifications?

会有一股神秘感。 提交于 2019-12-12 02:56:22

问题


When subscribing to real-time notifications, I go through the normal handshake, subscribe, connect flow. Once the connection returns with events, I reconnect and wait for the next response to return. My question is: If events are generated the first response and the next reconnect, could they be lost?

As an example: A synchronous application which processes returned response data after it returns and only reconnects once the data processing has finished could cause a significant delay between the response and the next reconnect. Are the cumulocity events generated during that delay buffered in the real-time queue for that particular client id or are they just lost?

Another possible example is when the client ID is no longer valid (this seems to happen every day at midnight), I have to resubscribe, causing a period of time during which no one is subscribed.


回答1:


The client ID that you receive when handshaking is connected to a queue on the server side. That queue keeps all notifications that you are not able to receive until the next connect. It delivers them when you reconnect. (Try it out with Postman: After a connect returns, send a couple of events, then connect again. You will notice that you will get all events at once.)

However, as you noticed, the queue is not kept forever. If you are not able to reconnect within two hours (I believe), the queue is thrown away in order to not block server resources. This is what you noticed. In that case, you need to query the database to determine any missed events (e.g., poll any operations in pending state from devices).



来源:https://stackoverflow.com/questions/35841237/is-it-possible-to-lose-events-when-using-long-polling-to-retrieve-real-time-noti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!