Show TOC

Synchronizing ServicesLocate this document in the navigation structure

Context

Messages sent to queue and sync services are only sent to the service instance on one of the cluster nodes, not all of them. Therefore, the instances of a queue or sync service may be in different states.

To enable you to keep instances of a service synchronized, RTMF provides a special message type - RTMFClusterMessage - that can be sent only from an RTMF service to the instances of that service. As with all messages, you can set parameters for an RTMFClusterMessage message, which can be used to help synchronize the sibling services.

Procedure


  1. Create an RTMFClusterMessage message.

    RTMFClusterMessage rtmfCM = new RTMFClusterMessage();
                         
  2. Add parameters to the message, if necessary.

    message.putParam("param","value");
                         
  3. Send the message to all instances of the service.

    try {
            rtmfCM.publishToCluster();
    } catch (RTMFException e) {
            e.printStackTrace();
    }
                         

    The onClusterMessageArrived() method is called on all the service instances for the current service, and the RTMFClusterMessage is passed as a parameter.

    Note

    The onClusterMessageArrived() method is also called on the service instance that initiated the synchronization, that is, the instance that called publishToCluster() .

    If you do not want to perform any action on the instance called publishToCluster() , add a parameter that indicates from which instance the call originated, and then check the parameter in the onClusterMessageArrived() method.