JSLEE Integration

Overview

The N2OCS may be run within a N-Squared JSLEE cluster environment by configuring it as a JSLEE service and providing configuration through the normal means. See the JSLEE technical guide online for more details.

A minimal JSLEE configuration for the execution of the OCS in this environment is:

{
  "applications": {
    "ocs": {
      "handler": "nz.co.nsquared.slee.ocs.OcsServerVerticle",
      "instance-count": 1,
      "configuration": {
        // base configuration
        "edr": {
            // EDR configuration
        },
        "notification": {
            // Notification configuration
        }
      }
    }
  }
}

The OCS primarily requires configuration to determine the database connection information. Refer to the configuration guide for detailed configuration options and information.

As with other JSLEE applications, the EDR configuration may be provided by using the edr configuration subsection within the configuration section of the JSON application configuration. Notification integration can be defined in detail with the notification subsection.

Hazelcast Configuration

The OCS requires specific configuration in the JSLEE’s Hazelcast configuration file. The following map & semaphore must exist (note that this is also defined in the Vert.x configuration guide):

    <!--
        Define vertx required hazelcast configuration options as per
        https://vertx.io/docs/vertx-hazelcast/java/
      -->
    <multimap name="__vertx.subs">
        <backup-count>1</backup-count>
    </multimap>
    <map name="__vertx.haInfo">
        <time-to-live-seconds>0</time-to-live-seconds>
        <max-idle-seconds>0</max-idle-seconds>
        <eviction-policy>NONE</eviction-policy>
        <max-size policy="PER_NODE">0</max-size>
        <eviction-percentage>25</eviction-percentage>
        <merge-policy>com.hazelcast.map.merge.LatestUpdateMapMergePolicy</merge-policy>
    </map>

    <!--
      Define the required Vert.x configuration for Hazelcast so that
      Cluster aware locks will correctly work in the OCS engine.
      -->
    <semaphore name="__vertx.*">
        <initial-permits>1</initial-permits>
    </semaphore>

Please ensure that this configuration is present in your JSLEE Hazelcast configuration, or cluster-aware locking will not operate as expected.

Performance Configuration

Improving cluster performance for the OCS requires several JSLEE configuration options to be configured.

Hazelcast Performance Configuration

For data storage, for any cluster members not responsible for data storage (e.g. diameter session data), enable the lite-member configuration in the hazelcast.xml configuration:

    <lite-member enabled="true"/>

This configuration option should be added to the Hazelcast XML configuration file.

JSLEE Performance Configuration

When configuring the JSLEE, configure the event bus to use appropriately sized TCP/IP configuration. In the JSLEE server.json, configure the event bus to use 8Mb buffers and enable several other performance improvements for the event bus:

"event-bus": {
  "receiveBufferSize": 8388608,
  "sendBufferSize": 8388608,
  "ssl": false,
  "tcpCork": true,
  "usePooledBuffers": true
}

note that ssl can be enabled, however it does have a performance impact. The Vert.X configuration should also be tweaked to improve the scale of the event bus:


"vertx-options": {
  "eventLoopPoolSize": 128,
  "preferNativeTransport": true
}

JSLEE Messaging API

Wallet Query

To query an wallet, create an OCS wallet request and send the request to the OCS application:

OcsAccountRequest walletRequest = new OcsAccountRequest("6463581140");
eventBus.send(new Address("testocs"), walletRequest, response -> {
    // Handle wallet response. This will fail if the wallet doesn't exist.
});

The OCS wallet request requires no further information other than the wallet ID.

Wallet Query Response

The wallet query response:

response -> {
    // Handle wallet response. This will fail if the wallet doesn't exist.
    if (response.failed()) {
        ReplyException replyException = (ReplyException) response.cause();
        if (replyException.failureCode() == 404) {
            // The wallet does not exist
        } else {
            // Another error has occurred.
        }
    } else {
        Account wallet = ((OcsAccountResponse)response.result().body()).getAccount();
        // Use the wallet.
    }
}