MigratoryDataPresenceListener

The implementation of this interface can handle user presence events such as user connections and user disconnections, as well as messages received from publishers and accepted by the cluster to be distributed to the subscribers. More…

Public Classes

Name
interface Message
Interface to handle messages accepted by the cluster.
interface User
Interface to handle user presence events.

Public Functions

Name
void onClusterMessage(Message message)
This method is called whenever the MigratoryData cluster accepts a message received from a publisher.
void onUserPresence(User user)
This method is called whenever a user connects to or disconnects from a cluster member.

Detailed Description

class MigratoryDataPresenceListener;

The implementation of this interface can handle user presence events such as user connections and user disconnections, as well as messages received from publishers and accepted by the cluster to be distributed to the subscribers.

It is guaranteed that each message received from a publisher is accepted by exactly one server of the cluster, which is the coordinator of the subject of that message. Publishers may connect to any server of the cluster. However, each message must pass through the coordinator of the subject of the message to be accepted by the cluster.

Thread safety

The methods exposed by this interface are always called from by same thread.

Public Functions Documentation

function onClusterMessage

void onClusterMessage(
    Message message
)

This method is called whenever the MigratoryData cluster accepts a message received from a publisher.

Parameters:

  • message the accepted message

The message is always accepted by the cluster member which is the coordinator of the subject of the message. So, this method is called once, only for the coordinator of the subject of the accepted message.

A publisher may publish a message to any cluster member, however, the MigratoryData cluster will forward the message to the cluster member which is the coordinator of the subject of the message in order to accept the message.

Each cluster member coordinates a distinct subset of subjects. In this way, at any given time, a subject is coordinated by at most one cluster member, always the same until that cluster member fails or is stopped. When a cluster member fails or is stopped, its subjects are automatically redistributed the remaining cluster members such that there are no two cluster members which coordinate simultaneously any given subject.

function onUserPresence

void onUserPresence(
    User user
)

This method is called whenever a user connects to or disconnects from a cluster member.

Parameters:

  • user the details about the user

This method is also called whenever a connected user changes its list of subscribed subjects (by subscribing to new subjects or unsubscribing from existing subjects). MigratoryData replicates this user presence event across the cluster and calls this method for each cluster member, not only for the cluster member to which the user connected to or disconnected from.


Updated on 9 November 2020 at 21:01:04 EET