Universal Messaging 10.7 | 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 NirvanaSession can be initialised to receive DataGroup events by passing a NirvanaCallback object into the connect method.
Creating a NirvanaCallback Object
Asynchronously receiving events requires an object which implements the NirvanaPython.NirvanaCallback interface. The interface has one method, onMessage which is passed a nConsumeEvent object (see Universal Messaging Events).

class NirvanaCallback(NirvanaPython.NirvanaCallback):
def onMessage(self,message):
print "received an event"

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

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