Universal Messaging 10.7 | Developer Guide | Enterprise APIs | Enterprise Developer's Guide for Python | Python Objects | Universal Messaging Events
 
Universal Messaging Events
A Universal Messaging Event (nConsumeEvent) is the object that is published to a Universal Messaging Channel, Queue or Data Group. It is stored by the server and then passed to consumers as and when required.
Events can contain simple byte array data, or more complex data structures such as an Universal Messaging Event Dictionary (nEventProperties).
Constructing an Event
In this Python code snippet, we construct our Universal Messaging Event object (nConsumeEvent), as well as a Universal Messaging Event Dictionary object (nEventProperties) for our Universal Messaging Event:

props = nEventProperties()
props.put("bondname", "bond1")
props.put("price", 100.00)
event = nConsumeEvent(props,"Tag")
Handling a Received Event
When a client subscribes to a channel and specifies a callback function to handle received events, the callback function will be invoked with the event as its parameter whenever an event is received.
In this Python code snippet, we demonstrate a simple implementation of such a callback function. In this example, we assume that the event contains an Event Dictionary with two keys: bondname and price.

class myCallback(NirvanaPython.NirvanaCallback):
def onMessage(self,event):
props = event.getProperties()
name = props.get("bondname")
price = props.get("price")
//do something with name and price