Show TOC

Procedure documentationSynchronizing Services Locate this document in the navigation structure

 

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.

    Syntax Syntax

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

    Syntax Syntax

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

    Syntax Syntax

    1. try {
    2. 	rtmfCM.publishToCluster();
    3. } catch (RTMFException e) {
    4. 	e.printStackTrace();
    5. }
    End of the code.

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

    Note 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.

    End of the note.