Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Market Data Management : Market data subscribers : Overriding default error handling for subscriptions
Overriding default error handling for subscriptions
By default, MDA invokes the default error handler if there is an error related to market data subscribers. For example, if any of the following happen:
*Subscription fails
*Delivery of subscribed data fails
*Unsubscription fails
The default error handler sends a message to the correlator log file at the ERROR level. To change this behavior, execute xxxSubscriber.addErrorCallback(), which adds the specified callback to the set of callbacks executed if there is an error related to that subscriber. An error handling callback that you define can use xxxSubscriber.defaultErrorCallback() to invoke the default error callback.
You can execute the addErrorCallback() action multiple times on the same subscriber to implement multiple error handling callbacks for that subscriber. If you add one or more error callbacks to a subscriber then the default error callback is not executed for that subscriber.
The parameters of a user-defined error callback include the subscriber object and also a com.apama.utils.Error event. An Error event has fields for a message, a dictionary of parameters, and an error type code. The addErrorCallback() action adds the specified callback to the set of callbacks executed if there is an error in the operation of the specified subscriber.
The com.apama.md.HandlerErrorConstants event defines the following error type codes for subscriptions:
*FAILED_TO_SUBSCRIBE
*FAILED_TO_UNSUBSCRIBE
*SESSION_ERROR
*DUPLICATE_SUBSCRIPTION
*UNKNOWN_UPDATE_CALLBACK
*UNKNOWN_SUBSCRIBED_CALLBACK
*UNKNOWN_UNSUBSCRIBED_CALLBACK
*UNKNOWN_ERROR_CALLBACK
When you add an error callback the return value is an integer reference ID that you can specify if you execute removeErrorCallback() to discontinue execution of that error callback. To remove all error callbacks, execute the xxxSubscriber.clearErrorCallbacks() action. If you remove all previously set error callbacks then error handling behavior reverts to calling the default error callback.
A callback is unknown if you specify an incorrect reference ID for a callback you are trying to remove with the xxxSubscriber.removeSubscribedCallback(), removeUpdateCallback() or removeUnsubscribedCallback() action.
The following code provides an example of adding an error callback to a subscriber.
using com.apama.session.SessionHandlerFactory;
using com.apama.session.SessionHandler;
using com.apama.md.TradeSubscriberFactory;
using com.apama.md.TradeSubscriber;
 
monitor SubscriberExample13 {
 
context mainContext := context.current();
 
action onload() {
SessionHandler sessionHandler :=
(new SessionHandlerFactory).connect(
mainContext, "MySession", "MyTransport");
 
TradeSubscriber tradeSubscriber :=
(new TradeSubscriberFactory).create(sessionHandler);
integer refId := tradeSubscriber.addErrorCallback(onError);
tradeSubscriber.subscribe("SOW");
 
// The following duplicate subscription causes an error.
tradeSubscriber.subscribe("SOW");
}
 
action onError( TradeSubscriber subscriber,
com.apama.utils.Error error ) {
 
// This error should be a DUPLICATE_SUBSCRIPTION type.
}
}
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback