Search code examples
google-app-enginechannel-api

Guarding against missed messages in AppEngine Channel API


In the AppEngine Channel API, channels automatically close after 2 hours. We are handling this by rejoining the channel in the onError event.

Is there a chance the messages could get missed if they are sent while the channel is reconnecting?

Our scenario: We have an appointment scheduling system where appointments are booked elsewhere through an API. We use the channel to display new appointments on the schedule as they arrive. But I'm concerned that some appointments could get missed if they are booked during the time when a channel is closed and reconnected. Does the Channel API guard against this?


Solution

  • A little bit of background: the "client id" in the Channel API is used to create a transient XMPP endpoint. A given client id will always map to the same transient endpoint. So when you re-connect using a token to a channel created with the same client id, you are reconnecting to the same endpoint. Because of this you might see behavior where your client gets messages sent before recreating the channel. But there are no guarantees and we don't actively queue messages when they're sent to a channel with no listening clients.

    In your case, could you return an up-to-date list of appointments as part of the same response that returns a new token?