Universal Messaging 10.3 | Developer Guide | Enterprise APIs | Enterprise Developer's Guide for C++ | Publish / Subscribe using Data Streams and Data Groups | DataGroup Conflation Attributes
 
DataGroup Conflation Attributes
Enabling Conflation on DataGroups
Universal Messaging DataGroups can be configured so that conflation (merging and throttling of events) occurs when messages are published. Conflation can be carried out in several ways and these are specified using a nConflationAttributes object. The ConflationAttributes object is passed in to the DataGroup when it is created initially.
The nConflationAttributes object has two properties action and interval. Both of these are passed into the constructor.
The action property specifies whether published events should replace previous events in the DataGroup or be merged with them. These properties are defined by static fields:

nConflationAttributes::sMergeEvents
nConflationAttributes::sDropEvents
The interval property specifies the interval in milliseconds between event fanout to subscribers. An interval of zero implies events will be fanned out immediately.
Creating a Conflation Attributes Object

//ConflationAttributes specifying merge events and no throttled delivery
nConflationAttributes* confattribs =
new nConflationAttributes(nConflationAttributes::sMergeEvent, 0);

//ConflationAttributes specifying merge events and throttled delivery at
// 1 second intervals
nConflationAttributes* confattribs =
new nConflationAttributes(nConflationAttributes::sMergeEvent, 1000);

//ConflationAttributes specifying drop events and throttled delivery at
// 1 second intervals
nConflationAttributes* confattribs =
new nConflationAttributes(nConflationAttributes::sDropEvent, 1000);
Create a Single nDataGroup with Conflation Attributes

//create a DataGroup passing in this class as a nDataGroupListener and
// a ConflationAttributes
myDataGroup = mySession->createDataGroup(dataGroupName, this, confattribs);
Create Multiple nDataGroups with Conflation Attributes

nConflationAttributes* confattribs =
new nConflationAttributes(nConflationAttributes::sMergeEvent, 1000);
std::string[] groups = {"myFirstGroup", "mySecondGroup"};
nDataGroup[] myGroups = mySession->createDataGroups(groups, confattribs);
Publishing Events to Conflated DataGroups With A Merge Policy
At this point the server will have a nDataGroup created with the ability to merge incoming events from Registered Events. The next step is to create the Registered events at the publisher.

nRegisteredEvent* audEvent = myDataGroup->createRegisteredEvent();
nEventProperties* props = audEvent->getProperties();
props->put("bid", 0.8999);
props->put("offer", 0.9999);
props->put("close", "0.8990");
audEvent->commitChanges();
You now have a nRegisteredEvent called audEvent which is bound to a ccy value of "AUD". We then set the properties relevant to the application, finally we call commitChanges(), this will send the event, as is, to the server. At this point if the bid was to change then that individual field can be published to the server as follows:

props->put("bid", 0.9999);
audEvent->commitChanges();
This code will send only the new "bid" change to the server. The server will modify the event internally so that any new client subscribing will receive all of the data, yet any existing subscribers will only receive the change.
Publishing Events to Conflated DataGroups With A Drop Policy
If you have specified a "Drop" policy in your ConflationAttributes then events are published in the normal way rather than using nRegisteredEvent.
Consuming Conflated Events from a DataGroup
The subscriber doesn't need to do anything different to receive events from a DataGroup with conflation enabled. If nRegisteredEvents are being delivered then the events will contain only the fields that have changed will be delivered. In all other circumstances an entire event is delivered to all consumers.