Just a second...

Types of message conflation

The types of conflation are simple conflation, where a new update replaces an older update, and structural conflation, where the data from two updates is combined in accordance with a user-defined operation to create a new update. Both types of conflation can either append the new update to the end of the queue or replace an existing update on the queue.

No conflation

Figure 1. Message flow without conflation enabled The messages are added to the queue in the following order: A1, B1, C1, A2, C2. They leave the queue in the same order: A1, B1, C1, A2, C2.

With no conflation, a stream of messages to a client is delivered to the client in the order that they are published or sent. In example shown in the diagram, two messages for topic A, one message for topic B, and two messages for topic C are ready to send to the client.

This is a scenario common to all messaging platforms.

Simple conflation

When a new message is published or sent to a topic, simple conflation removes any earlier messages for that topic from the queue. The new message can be added to the queue either in the position of the earlier message that was removed (replace) or at the end, preserving the original message order (append).

Figure 2. Message flow with simple replace conflation enabled The messages are added to the queue in the following order: A1, B1, C1, A2, C2. The first messages for topics A and C are replaced by the newer message on their respective topic. The messages leave the queue in the following order: A2, B1, C2.

With simple replace conflation, only the most recent message for a topic is delivered to the client. In the example shown in the diagram, the first message published or sent to topic A is removed and the second message is added to the queue in the position that the first message occupied. The same occurs for the messages sent to topic C.

Figure 3. Message flow with simple append conflation enabled The messages are added to the queue in the following order: A1, B1, C1, A2, C2. The first messages for topics A and C are removed when newer messages are sent or published to their respective topics. The newer messages are added to the end of the queue. The messages leave the queue in the following order: B1, A2, C2.

With simple append conflation, only the most recent message for a topic is delivered to the client. Messages are delivered in time order. In the example shown in the diagram, the first message published or sent to topic A is removed and the second message is added to the end of the queue. The same occurs for the messages sent to topic C.

Note: Use this option with care because there is the possibility that messages for a topic can continue to be added to the end of the queue and a value not be delivered for the topic.

In both the append and the replace example, although five messages were ready to send, only three messages were sent. This saves bandwidth and ensures clients receive current data only.

Structural conflation

Structural conflation allows a user-defined operation to be plugged into Diffusion™ so that rather than refreshing stale data with fresh data, a computation can be performed to merge, aggregate, reverse or combine the effects of multiple changes into a single consistent and current notification to the client.

Figure 4. Message flow with merge and replace conflation enabled Messages that contain a numerical value field are published to one of three topics: A, B, or C. The messages arrive on the queue in the following order: A1 with a value of 1, B1 with a value of 2, C1 with a value of 3, A2 with a value of 4, C2 with a value of 5. The messages A1 and A2 are conflated to make a new message, A3, which is added to the queue in the position occupied by A1. The value for A3 is the summation of the values of A1 and A2. The messages C1 and C2 are conflated to make a new message, C3. The value for C3 is the summation of the values of C1 and C2, which is added to the queue in the position occupied by C1. The messages leave the queue in the following order: A3 with a value of 5, B1 with a value of 2, C3 with a value of 8.

In the example shown in the diagram, the operation is the summation of numeric data. The user provides the merge algorithm, that is the summing of the values of two successive messages, and Diffusion sends a single resulting message rather than the individual messages that were combined. The messages A3 and C3 are new messages generated from the merging process.

This is suitable for any scenario where the result is required but individual components that combine to form the result are not required.

The preceding example shows merge and replace. You can merge and append in a similar way as described for simple conflation above.

Various options are available to the user-written merger so that instead of returning a merged message it can indicate that either of the input messages be queued or that the no conflation option be chosen.

Selection of messages for conflation

The preceding examples assume that when a new message is queued for a client it replaces or merges with the last message queued for the message topic. This is the default behavior. When operating conflation in this way there is only ever one message per conflated topic awaiting delivery to the client.

You can specify a user-defined matcher that is used to determine the message that is to be replaced or merged with. This can be used to inspect the content of the messages queued for a topic to select which to conflate. When operating conflation in this way it is likely there can be more than one message per conflated topic awaiting delivery to the client.