Skip to content

Message Handling

This page looks at how the Clustered Service handles inbound messages. Here's another copy of the final structure of the Clustered Service after starting:

<counters> cnc.dat ClientSession log Log Subscription egress Egress Publications service ServiceAdapter Consensus Module Publication ConsensusModuleProxy BoundedLogAdapter ClusteredServiceAgent Service Subscription consensus module Archive.Context Transport Client ClusterMarkFile Clustered Service cluster-mark- service-0.dat Your Application ClusteredService

BoundedLogAdapter

The BoundedLogAdapter is used to receive Log messages from its Log Subscription. The Log Subscription can be receiving messages from the live Log Publication on the leader, or it could be in an Election, replaying Log messages from its Log Recording. The Clustered Service does not know or care which. This is all set up by the Consensus Module, which tells the Clustered Service to join the Log specified in a JoinLog message.

The ClusteredServiceAgent polls the BoundedLogAdapter, which polls the Log Subscription. The BoundedLogAdapter is passed the commit-pos Counter value to use as the upper bound in the Log Subscription poll. The Counter value is set by the Consensus Module. This ensures that the Clustered Service does not process messages that might be in the Log, but which have not yet reached the Raft Committed status.

For each message returned by the Log Subscription, the BoundedLogAdapter unpacks the field values and calls a corresponding method on the ClusteredServiceAgent, e.g. SessionMessageHeader goes to onSessionMessage(). This is all the BoundedLogAdapter does.

Each method called on the ClusteredServiceAgent calls a corresponding method on the ClusteredService, e.g. onSessionMessage(). The ClusteredServiceAgent may do more work, e.g. when asked to take a snapshot (ClusterActionRequest), it also sends a ServiceAck back to the Consensus Module.

It handles the following messages:

ServiceAdapter

The ServiceAdapter is used to receive Service messages from its Service Subscription. These are messages from the Consensus Module to the (Clustered) Service.

The ClusteredServiceAgent polls the ServiceAdapter, which polls the Service Subscription. For each message returned by the Service Subscription, the ServiceAdapter unpacks the field values and calls a corresponding method on the ClusteredServiceAgent, e.g. JoinLog goes to onJoinLog(). This is all the ServiceAdapter does.

It handles the following messages:

These messages are processed by the ClusteredServiceAgent and do not result in calls into the ClusteredService. They are not a second channel of inputs that could cause inconsistent state across the ClusteredServices.