Universal Messaging 9.7 | Universal Messaging Developer Guide | Enterprise APIs | Enterprise Developer's Guide for Java | Publish / Subscribe Using Channels/Topics | Event Fragmentation on Channels
 
Event Fragmentation on Channels
By default, Universal Messaging will only allow events to be published if the size of the event is less than 1Mb. Although this limit can be changed in the Enterprise Manager (see Config tab, FanoutValues/MaxBufferSize), this is not generally recommended; it is usually far more efficient to fragment large events into smaller chunks for publishing.
Universal Messaging can transparently fragment and reconstruct events. Thus, a developer need only invoke one method call to fragment and publish an event. In the same way, the resulting event will be transparently reconstructed when received by the consumer. Under the hood, however, Universal Messaging will publish several smaller messages representing the large event.
A summary of the code needed to publish and consume fragmented events is provided below.
Publishing
The code to publish a large event using fragmentation is as follows:

// The chunk_size is the max size (bytes) for each event. Multiple events will
// be published of size chunk_size until the entire event has been sent.
int chunk_size = 50000;

fw = new nConsumeEventFragmentWriter(myChannel,chunk_size);

// Rather than myChannel.publish(evt), we let the fragment writer handle the publish
fw.publish(evt)
Subscribing
The code to consume a large event using fragmentation is as follows:

// In this example the enclosing class implements nEventListener
fr = new nConsumeEventFragmentReader(this);

// Rather than directly add 'this' as the nEventListener, add the new fragment reader
myChannel.addSubscriber(fr);

Copyright © 2013-2015 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.