View examples for:

On this page:

# Receiving messages

Receiving updates from topics requires two actions:

1) Register a value stream. A value stream is a way for a session to listen to subscription events and updates from topics.

2) Make a subscription request. This tells Diffusion that the session would like to receive updates for one or more particular topics.

# Adding a value stream

Value streams make it easy for separate application components to listen to the same set of remote updates without having to coordinate between each other. You can register as many value streams as you need to ensure your application is ready to receive data before making any subscriptions.


Value streams are typed: you need to specify a topic type (such as JSON) for a stream, and it will only match topics of the correct type. This ensures that delta updating can work correctly.

# Subscribing to a topic

To actually start receiving topic updates, you can subscribe to one or more topics. If the subscription is succesful, any value streams you have registered will begin to receive updates. Subscriptions are stored in Diffusion, meaning that a session will remain subscribed to selected topics until it unsubscribes, or it is closed.


Subscriptions are subject to authorisation rules. If the session you are using doesn't have permission to subscribe to the requested topic path, the subscription request will be rejected with an error message. For more information on permissions, please refer to the security section.

# Unsubscribing

Unsubscribing from topics works in just the same way. Once you unsubscribe from a topic, you will no longer receive any updates for it. You can subscribe and unubscribe from as many topics and as many times as you like.


Unsubscribing will not affect any value streams you have active. This means you can use the same value stream for receiving updates, even if you subscribe and unsubscribe multiple times.