Universal Messaging Developer Guide : Enterprise APIs : Enterprise Developer's Guide for Python : Enterprise Client Development : Asynchronous Exception Listener
Asynchronous Exception Listener
Certain methods within the Universal Messaging Python Client API require synchronous calls to the server. For example the Universal MessagingSession.getLastEID method will request the most recent event ID that was published onto a Universal Messaging Channel. This method is required to be synchronous i.e. must block until a response is received. Other methods such as Universal MessagingSession.publish do not require a response so to make these methods as fast as possible, they are asynchronous.
With synchronous calls, if an exception is thrown on the server e.g. the user does not have permission to get the last event ID then the exception is passed back in the response and thrown on the client.
With asynchronous calls, the client does not wait for a response so if an exception is thrown on the server e.g. the user does not have permission to publish, the client will not know that the event was not successfully published. This is where it is useful to have an Asynchronous Exception Listener.
The Asynchronous Exception Listener will receive notification of exceptions that occurred on the server for asynchronous calls. So if the user was not allowed to publish, the listener will be notified with a message indicating this.
Creating a Asynchronous Exception Listener
Asynchronously receiving exceptions requires an object which implements the Universal MessagingPython.AsyncExceptionListener interface. The interface has one method, onException which is passed a string describing the exception.

class AsyncExceptionListener(Universal MessagingPython.AsyncExceptionListener):
def onException(self,message):
print "Received an exception -> "+message

exceptionListener = AsyncExceptionListener()
Registering the listener for events
In order to register the Universal MessagingPython.AsyncExceptionListener to receive notification of exceptions, you can call the addAsyncExceptionListener method of Universal MessagingSession (see Creating a Session).

mySession = Universal MessagingSession()
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback