Scaling Subscribers

To add or remove subscribers running on different nodes, NoSQLSubscriptionConfig has to be created with the following additional builder API.
/* step 3: create a subscription configuration */
  final NoSQLSubscriptionConfig subscriptionConfig =
    // Scalable subscriber should set Subscriber Id
    // with 2 as total number of subscribers and
    // 0 as its own SubscriberId within the group of 2 subscribers

    new NoSQLSubscriptionConfig.Builder(CKPT_TABLE_NAME)
    .setSubscribedTables("usertable")
    .setSubscriberId(new NoSQLSubscriberId(2,0))
    .setStreamMode(streamMode)
    .build();

The API setSubscriberId() takes a single argument NoSQLSubscriberID. NoSQLSubscriberId is an object with both total number of subscribers and subscriber index. Hence, we need the following two arguments to construct a NoSQLubscriberId object.

  • Number of Subscribers

    The total number of subscribers that would be running on different nodes. For example, in the code example above, .setSubscriberId(new NoSQLSubscriberId(2,0)), the NoSQLSubscriberId created has two subscribers in total.

  • Subscriber Index

    A numerical index of the current subscriber among the total number of subscribers. Note that a numerical index begins with 0. For example, two subscriber clients can be identified as 0 and 1.