Namespace: topics

diffusion. topics

Provide access to TopicType and UnsubscribeReason

Members

<static, readonly> TopicAddFailReason

The reason that a topic could not be added.
Properties:
Name Type Default Description
EXISTS {"id":1,"reason":"The topic already exists with the same details"} The topic already exists with the same details.
EXISTS_MISMATCH {"id":2,"reason":"The topic already exists, with different details"} The topic already exists, with different details.
INVALID_PATH {"id":3,"reason":"The topic path is invalid"} The topic path is invalid.
INVALID_DETAILS {"id":4,"reason":"The topic details are invalid"} The topic details are invalid.
USER_CODE_ERROR {"id":5,"reason":"A user supplied class could not be found or instantiated"} A user supplied class could not be found or instantiated.
TOPIC_NOT_FOUND {"id":6,"reason":"A referenced topic could not be found"} A referenced topic could not be found.
PERMISSIONS_FAILURE {"id":7,"reason":"Invalid permissions to add a topic at the specified path"} Invalid permissions to add a topic at the specified path.
INITIALISE_ERROR {"id":8,"reason":"The topic could not be initialised, supplied value may be of the wrong format"} The topic could not be initialised, supplied value may be of the wrong format.
UNEXPECTED_ERROR {"id":9,"reason":"An unexpected error occured while creating the topic"} An unexpected error occured while creating the topic.
Example
session.topics.add("foo").then(function() { ... }, function(err) {
    switch (err) {
         case diffusion.topics.TopicAddFailReason.EXISTS:
             ...
         case diffusion.topics.TopicAddFailReason.INVALID_PATH:
             ...
    }
});

<static, readonly> TopicType

Enum containing possible Topic Types.
Properties:
Name Type Default Description
STATELESS Stateless Topic.

A stateless topic is one that has no data maintained at the server and performs no specific function. Such a topic would normally be used simply to act as an organisational node within the topic tree but may also be used for sending messages.

SINGLE_VALUE Single value topic.

This is a stateful topic that maintains its state as a single String value which may optionally be validated and constrained by type (e.g diffusion.metadata.Integer, diffusion.metadata.Decimal). The type is defined by a diffusion.metadata instance.

RECORD Record topic.

This is a stateful topic that maintains its state in record format. The format of the topic content may be one or more Records as defined by an item of diffusion.metadata.MRecordContent metadata. When such a topic is updated, the metadata is used to interpet the data and make comparisons between the current topic state and the update such that a delta of change can be calculated for publishing to subscribed clients.

PROTOCOL_BUFFER
CUSTOM Custom Topic.

A stateful topic that maintains its state via a user written Java class deployed at the server.

Deprecated since 5.9. This topic type will removed in future versions of Diffusion

SLAVE Slave Topic.

A topic that references another topic (the master topic) which has data (i.e. an alias). It effectively allows a topic's data to be shared across more than one topic node.

A client cannot tell that it is subscribed to a slave topic. A client requesting details of a slave topic will receive the details of the master topic. A client subscribing to the slave topic will receive all updates to the master topic. The slave topic itself may not be updated.

Any number of slave topics may reference the same master topic.

If a topic is removed that referenced by slave topics, all such slave topics are also automatically removed.

Slave topics are unable to be created by the Javascript client, but may safely be subscribed to.

SERVICE Deprecated
PAGED_STRING Paged String Topic.

A functional topic that maintains its state as a list of Strings which individual clients can page through and be dynamically notified of changes.

Currently paged topics may only be used by user of the classic API.

Deprecated since 5.9. This topic type will removed in future versions of Diffusion

PAGED_RECORD Paged String Topic.

A functional topic that maintains its state as a list of Strings which individual clients can page through and be dynamically notified of changes.

Currently paged topics may only be used by user of the classic API.

Deprecated since 5.9. This topic type will removed in future versions of Diffusion

TOPIC_NOTIFY Deprecated
ROUTING Routing Topic.

A functional topic that can point to different target topics for different clients.

From the point of view of a client subscribing to such a topic this would be seen as a normal stateful topic but it has no state of its own and cannot be published to.

Such a topic may specify a user written Java class which will be invoked to define the mapping of the topic to another data topic when a client subscribes. Alternatively the mapping can be delegated to a control client using the SubscriptionControl feature.

CHILD_LIST Deprecated
BINARY Binary Topic.

This is a stateful topic that handles data in Binary format.

JSON JSON (JavaScript Object Notation) Topic.

This is a stateful topic that handles data in JSON representation.

Example
// Get a topic type for adding topics
var topicType = diffusion.topics.TopicType.JSON;

session.topics.add("foo", topicType);

<static, readonly> UnsubscribeReason

Enum containing reasons that an unsubscription occurred.
Properties:
Name Type Default Description
SUBSCRIPTION_REFRESH The server has re-subscribed this session to the topic. Existing streams are unsubscribed because the topic type and other attributes may have changed.

This can happen if a set of servers are configured to use session replication, and the session connected to one server reconnects ("fails over") to a different server.

A stream that receives an unsubscription notification with this reason will also receive a subscription notification with the new TopicSpecification or TopicDetails.

STREAM_CHANGE A fallback stream has been unsubscribed or subscribed due to the addition or removal of a stream that selects the topic.
REQUESTED The unsubscription was requested by this client.
CONTROL The server or another client unsubscribed this client.
REMOVED The topic was removed
AUTHORIZATION The unsubscription occurred because the session is no longer authorized to access the topic.
Example
// Use UnsubscribeReason to validate unsubscription notifications
session.subscribe(">foo").on('unsubscribe', function(reason, topic) {
    switch (reason) {
        case diffusion.topics.UnsubscribeReason.REMOVED :
            // Do something if the topic was removed
        default :
            // Do something else if the client was explicitly unsubscribed
    }
});

<static, readonly> UpdateFailReason

The reason that a topic could not be updated.
Properties:
Name Type Default Description
INCOMPATIBLE_UPDATE The update was of a type that is not compatible with the topic it was submitted for, or the topic does not support updating.
UPDATE_FAILED The update failed, possibly because the content sent with the update was invalid/incompatible with topic type or data format.
INVALID_UPDATER The updater used is not active.
MISSING_TOPIC The topic being updated does not exist.
INVALID_ADDRESS Invalid key or index used for addressing topic content.
DUPLICATES Violation of content duplication restrictions.
EXCLUSIVE_UPDATER_CONFLICT Attempt to perform a non-exclusive update to a topic branch that already has an update source registered to it.
DELTA_WITHOUT_VALUE An attempt has been made to apply a delta to a topic that has not yet has a value specified for it.
Example
session.topics.update("foo", "bar").then(function() { ... }, function(err) {
    switch (err) {
        case diffusion.topics.UpdateFailReason.MISSING_TOPIC:
            ...
        case diffusion.topics.UpdateFailReason.EXCLUSIVE_UPDATER_CONFLICT:
            ...
    }
});