Class: TopicSpecification

diffusion.topics TopicSpecification


new TopicSpecification(type [, properties])

Topic specifications provide the information required to create a topic. Topics can be created from a topic specification using Session.topics#add.

Topic specifications allow an application to introspect the type and capabilities of a topic. Topic specifications are provided to ValueStreams and topic notification listeners.

A topic is specified in terms of its type and a map of optional property settings which can alter the default behavior of the topic.

Topic Properties

Depending on the topic type, some properties must be included in the specification when creating a topic and some properties have no effect. All topic specification property values must be supplied as strings.

The required and optional properties for each topic type are set out in the following table.

STRING
JSON
BINARY
DOUBLE
INT64
ROUTING
SLAVE TIME_SERIES RECORD_V2
COMPRESSION Optional - Optional Optional Optional Optional
CONFLATION Optional Optional Optional Optional Optional Optional
DONT_RETAIN_VALUE Optional Optional Optional Optional
PUBLISH_VALUES_ONLY Optional Optional Optional
SCHEMA Optional
SLAVE_MASTER_TOPIC Required
TIDY_ON_UNSUBSCRIBE Optional Optional Optional Optional Optional Optional
TIME_SERIES_EVENT_VALUE_TYPE Required
TIME_SERIES_RETAINED_RANGE Optional
TIME_SERIES_SUBSCRIPTION_RANGE Optional
VALIDATE_VALUES Optional Optional Optional
PERSISTENT Optional Optional Optional
REMOVAL Optional Optional Optional
OWNER Optional Optional Optional

‡ Prefer the RECORD_V2 topic type for Diffusion record data since it provides full support for topic specifications.

Parameters:
Name Type Argument Default Description
type diffusion.topics.TopicType

The topic type for this specification.

properties Object <optional>
{}

The properties to use for this specification.

Since:
  • 5.9
Examples

Properties can be set when creating the specification by passing an object

// Create specification, to be used for creating JSON topics which validate update values on the server
const TopicSpecification = diffusion.topics.TopicSpecification;

var specification = new TopicSpecification(diffusion.topics.TopicType.JSON, {
    "VALIDATE_VALUES" : "true"
});

New specifications can be created with additional properties

// Create specification, to be used for creating JSON topics which validate update values on the server
const TopicSpecification = diffusion.topics.TopicSpecification;

var specification = new TopicSpecification(diffusion.topics.TopicType.JSON)
    .withProperty(TopicSpecification.VALIDATE_VALUES, "true");