Just a second...

Messaging

In addition to publishing data to topics as updates, you can send data as messages to specific clients or to registered message handlers on topic paths.

Messaging and pub-sub are separate capabilities. Messaging uses topic paths to route the messages, but does not use the topics bound to those paths. Sending messages does not change the state of data on the topic, nor does it cause updates to be sent.

There are two ways in which messages are sent through topic paths:

Send messages to a topic path

Figure 1. A client registers a handler on part of the topic tree A client registers a handler on a part of the topic tree. This client receives any messages that are sent on topic paths in that part of the topic tree.

A client with the send_to_message_handler permission can send messages on a topic path. The sending client does not know which client, if any, receives the message.

A client with the register_handler permission can register a handler on a part of the topic tree. This client receives any messages that are sent on topic paths in that part of the topic tree.

Send messages to a client session

Figure 2. A client can send messages through a topic path to known client sessions A client that knows about other client sessions sends messages through a topic path to those client sessions.

A client with the send_to_session and view_session permissions that knows the session ID of a client session can send messages through a topic path to the known client session.

The receiving client must have a message stream registered against a topic path to receive messages sent through that topic path. For more information, see Streams.

Considerations when using messaging

  • The data type of the value sent in the message is not required to match the data type of the topic, if any, bound to the topic path you use to send the message.
  • A message can include headers. These headers are a set of string values that are separate to the message content.
  • You can set a priority on messages sent to client sessions. This priority affects the order in which the messages are queued on Diffusion™ Cloud for delivery to the client.
  • When considering the format of your data, be aware that the maximum size for a topic update or a message sent through Diffusion Cloud is 1 MiB.