Date: 2021-01-26
Accepted (lazy consensus).
Relates to 45. Support JMAP Push with Mailbox/changes implementation
Requires 46. Generalize EventBus
JMAP Push notifications allow clients to efficiently update (almost) instantly to stay in sync with data changes on the server.
In order to support this, we need to have the server emit newest state changes to the client over a PUSH channel.
We will implement RFC-8887 - A JSON Meta Application Protocol (JMAP) Subprotocol for WebSocket as a transport mechanism for PUSH notifications.
We will generalize EventBus in order to achieve an out-of-the box Publish-Subscribe system for JMAP related events, that does not fit in the mailbox API.
We will implement listeners registered on the JMAP event bus for WebSocket clients in order to carry over state changes to the client.
We expect clients using the PUSH to lead to a drastic performance enhancement, as less data needs to be transmitted upon resynchronisation.
As mentioned in RFC-8887 the usage of webSockets allows other performance optimizations:
People deploying JMAP need to be aware that load-balancing webSockets requires session stickiness.
ws://
endpoints. Upgrade to websockets is granted.Added
event is fired on the mailbox event bus.MailboxChangeListener
processes the Added event, handles delegation, records the state change, and fires related events for each account on the JMAP event bus, for both Email
(as there is an addition) and Mailbox
(as the counts were updated).Email/changes
, Email/get
, Mailbox/changes
and Mailbox/get
.Event bus listener are created for each socket upon client requests, and removed upon disconnection or when PUSH is explicitly canceled by the client.
In a multi-node setup, the event bus registration key mechanism described in this ADR and its distributed implementation ensure events are routed to the James servers holding client PUSH registration. We will use the AccountId as a base for a registration key.
The JMAP RFC defines event source (Server Sent Events) as a supported transport medium for PUSH notification. Yet:
Note that nothing refrains about future implementation of event source mechanism, that, if need be can be ignored or disabled via a reverse proxy.