Handling acknowledgments
Apama applications can call DBUtil SQL command and query actions as well as commit and rollback actions that request a DBAcknowledgement event. The DBAcknowledgement event indicates the success or failure of the action call. This is useful, for example, to know whether or not a query has completed before performing another application operation.
The DBAcknowledgement event is defined in apama_install_dir\adapters\monitors\ADBCHelper.mon as follows:
event DBAcknowledge
{
integer ackNum;
boolean success;
string error;
}
ackNum — A unique identifier for the action that requested the acknowledgment.
success — A value of true indicates success; false indicates failure.
error — A string describing the specific error.
For action calls that request an acknowledgement, your application needs to do the following:
1. Call an action that requests an acknowledgement, passing in a unique acknowledgment identifier.
2. Create an instance of the com.apama.database.DBAcknowledge event.
3. Create a listener for theDBAcknowledge event that matches the acknowledgment identifier in the calling action.
For example:
integer ackId := integer.getUnique();
db.doSQLQueryAck("SELECT * FROM NetworkInformation", handleNetworkInfo,ackId,false);
com.apama.database.DBAcknowledge ack;
//...
on DBAcknowledge(ackNum = ackId) : ack {
if ack.success then {
log "Query complete" at INFO;
}
else {
log "Query failed: " + ack.error at ERROR;
die;
}
}
//...
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.