The CallbackHandler interface is invoked when any database event occurs. A default callback handler is provided, which basically does nothing. You should implement a custom CallbackHandler to register important events. The callback is invoked on the thread that is processing the event. To receive callbacks for database changes, you must register a CallBackHandler with the generated database class, the entity class, or both. You can create a handler by extending the DefaultCallbackHandler class or by implementing the com.sybase.persistence.CallbackHandler interface.
In your handler, override the particular callback that you are interested in (for example, void onReplayFailure(java.lang.Object entity) ). The callback is executed in the thread that is performing the action (for example, replay). When you receive the callback, the particular activity is already complete.
Callback | Description |
---|---|
void onImport(java.lang.Object entity) |
This method is invoked when an import message is successfully applied to the local database. However, it is not committed. One message from server may have multiple import entities and they would be committed in one transaction for the whole message. Note:
Parameters:
|
void onLoginFailure() |
This method will be invoked when login failed for a beginOnlineLogin call. Note:
|
void onLoginSuccess() |
This method is invoked when login succeeds for a beginOnlineLogin call. Note:
|
void onReplayFailure(java.lang.Object entity) |
This method is invoked when a replay request fails. Note: CallbackHandlers registered for both the MBO class of the
entity and the Package DB are invoked.
Parameters:
|
void onReplaySuccess(java.lang.Object entity) |
This method is invoked when a replay request succeeds. Note: CallbackHandlers registered for both the MBO class of the
entity and the Package DB are invoked.
Parameters:
|
void onSearchFailure(java.lang.Object entity) |
This method is invoked when a back-end search fails. Note:
Parameters:
|
void onSearchSuccess(java.lang.Object entity) |
This method is invoked when a back end search succeeds. Note:
Parameters:
|
void onSubscribeFailure() |
This method is invoked when subscribe fails. Note:
|
void onSubscribeSuccess() |
This method is invoked when subscribe succeeds. Note:
|
int onSynchronize(GenericList<SynchronizationGroup> groups, SynchronizationContext context) |
This method is invoked at different stages of the synchronization. The status of the synchronization context specifies the stage of the synchronization. Parameters:
Returns: Either SynchronizationAction.CONTINUE or Synchronization.CANCEL. If
SynchronizationAction.CANCEL is returned, the
synchronize is cancelled if the status of the synchronization
context is one of the following.
|
void onSuspendSubscriptionFailure() |
This method is invoked when suspend subscription fails. Note:
|
void onSuspendSubscriptionSuccess() |
This method is invoked when suspend subscription succeeds. Note:
|
void onResumeSubscriptionFailure() |
This method is invoked when resume subscription fails. Note:
|
void onResumeSubscriptionSuccess() |
This method is invoked when resume subscription succeeds. Note:
|
void onUnsubscribeFailure() |
This method is invoked when unsubscribe fails. Note:
|
void onUnsubscribeSuccess() |
This method is invoked when unsubscribe succeeds. Note:
|
void onMessageException(java.lang.Exception ex) |
This method is invoked when an exception occurs in the processing of a message. Note: In DefaultCallbackHandlers,
onMessageException re-throws the
Exception so that the messaging layer can retry the message. The
application developer has the option to implement a custom
CallbackHandler that does not re-throw the exception, based on
exception types or other conditions, so that the message is not
retried.
Parameters:
|
void onTransactionCommit() |
This method is invoked after a message is processed and committed. Note:
|
void onTransactionRollback() |
This method is invoked after a message is rolled back. It only happens when an Exception was thrown when processing the message, or from a custom Callback method. Note:
|
void onResetSuccess() |
This method is invoked when all data is cleared by the reset. Note:
|
void onRecoverSuccess() |
This method is invoked when recover succeeds. Note:
|
void onRecoverFailure() |
This method is invoked when recover fails. Note:
|
void onSubscriptionEnd() |
This method is invoked when a subscription is re-registered or unsubscribed. This method deletes all MBO data on the device. Note:
|
void onImportSuccess() |
This method is invoked when all data has been successfully imported. Note:
|
void beforeImport(java.lang.Object entity) |
This method is invoked before importing the specified entity. Note:
Parameters:
|
This code shows how to create and register a handler to receive callbacks:
public class MyCallbackHandler extends DefaultCallbackHandler { // implementation } CallbackHandler handler = new MyCallbackHandler(); <PkgName>DB.registerCallbackHandler(handler);