Universal Messaging Events
A Universal Messaging Event (nConsumeEvent) is the object that is published to a Universal Messaging Channel, Queue, DataGroup or P2P service. 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()
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(Universal MessagingPython.Universal MessagingCallback):
props = event.getProperties()
name = props.get("bondname")
price = props.get("price")
//do something with name and price