A topic that provides data in string format. The data is transmitted in a binary form
for increased efficiency. String topics are stateful: each topic stores a JSON value on the Diffusion™ server.
Why use a string topic?
A string topic enables you to explicitly type the data that you send through the topic as a
String topics support null data values.
Deltas of change are calculated at the Diffusion server such that only those
parts that have changed since the last update are sent out to the subscribed clients. This
ensures that the minimum amount of data is sent to clients.
The current value of the topic is cached on the client. When deltas are sent, the client
can automatically apply these deltas to the value to calculate the new value.
The value of the topic is stored and transmitted as a CBOR-encoded string, or Concise Binary Object Representation (CBOR) Null. CBOR encodes
strings using UTF-8. For more information about CBOR, see
Properties of a string topic
When you create a string topic you can specify the following properties in the topic specification:
- By default, delta streaming is enabled.
If this property is set to true, delta streaming is disabled and
all values are published in full.
If there is little or no relationship between one value published to a topic and the next,
delta streams will not reduce the amount of data transmitted. For such topics, it is
better to set PUBLISH_VALUES_ONLY.
- If set to true, the latest value of the topic is not retained by
the Diffusion server or the client that publishes it.
New clients that subscribe do not receive an initial value. No value will be returned for fetch operations that select the topic.
For time series topics, if DONT_RETAIN_VALUE is set to true,
time series events are still retained, but the latest value is not stored separately.
The DONT_RETAIN_VALUE property is useful for applications like a
feed of news items, or for values that are only valid at the moment of publication.
You can combine this with VALIDATE_VALUES.
Using DONT_RETAIN_VALUE reduces the topic memory footprint, but disables delta streaming.
Using an update stream will send complete values to the server, instead of deltas.
Disabling delta streaming is likely to increase the bandwidth used unless subsequent values are unrelated.
This property replaces the obsolete stateless topic type which was removed in Diffusion 6.2.
- If set to true, when a session unsubscribes from
the topic, any updates for the topic that are still queued for the session are
There is a performance overhead to using this option as the client queue must be
scanned to find topic updates to remove, however it may prove useful for preventing
unwanted data being sent to sessions. This property is disabled by default.
- If set to true, the topic rejects updates that would
create invalid instances of the topic's data type.
If set to anything other than
true, no validation is performed and all values are streamed to
subscribing clients whether they are valid data or not.
Validation has a performance overhead and is disabled by default.
Note: If validation is disabled and the value provided is not valid, the client might
produce errors or other unexpected behavior. The exact error varies depending on the
client platform. To avoid this, use the client-side validation method provided by
the Diffusion API.
- Used to set a conflation policy for the topic. Conflation can
merge or discard topic updates to reduce server memory and network data usage.
The supported values are:
The default is "conflate".
See Using conflation for details of the policies.
- Used to set a security principal as the owner of the topic.
The principal receives READ_TOPIC, MODIFY_TOPIC
and UPDATE_TOPIC privileges.
The format of the property value is:
$Principal is "name"
where name is the name of the principal.
- Used to set a topic removal policy.
The property is an expression which defines the conditions which will trigger automatic removal
of the topic or of a set of topics specified with an optional selector.
See Removing topics automatically for details of the expression format.
- Used to disable persistence for a topic.
If set to "false", the topic will not be persisted, even if persistence
is enabled for the server.
Considerations when using a string topic