Universal Messaging 9.8 | Universal Messaging Developer Guide | Enterprise APIs | Enterprise Developer's Guide for Python | Enterprise Client Development | DataStream - Receiving DataGroup Events
 
DataStream - Receiving DataGroup Events
Python clients can (optionally) act as a DataStream, which allows them to receive events from DataGroups of which they are made members.
The Universal MessagingSession can be initialised to receive DataGroup events by passing a Universal MessagingCallback object into the connect method.
Creating a Universal MessagingCallback Object
Asynchronously receiving events requires an object which implements the Universal MessagingPython.Universal MessagingCallback interface. The interface has one method, onMessage which is passed a nConsumeEvent object (see Universal Messaging Events).

class Universal MessagingCallback(Universal MessagingPython.Universal MessagingCallback):
def onMessage(self,message):
print "received an event"

listener = Universal MessagingCallback()
Registering as a DataStream
In order to register the Universal MessagingSession as a DataStream, you simply need to pass the Universal MessagingCallback object into the connect method of Universal MessagingSession along with the RNAME (see Creating a Session).

mySession = Universal MessagingSession()
mySession.connect("nsp://localhost:9000",listener)

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.