Library Version 12.1.6.0

Event Handling
Prev | Chapter 1. Introduction | Next

## Event Handling

The replication system is capable of reporting a great many events to which your code might need to respond. To track and respond to these events, you implement a class whose function it is to respond to events that happen within the DB library.

In order to respond to events, you must write your application as an implementation of `com.sleepycat.db.EventHandler`. This class gives you a series of methods within which you can detect and respond to various events that occur in your DB code. Note that some of these are necessary for events beyond those required for replication. In this section, however, we only discuss some of the replication-specific events.

Some of the more commonly handled replication events are described below. For a complete list of events, see the `com.sleepycat.db.EventHandler` javadoc page.

- `EventHandler.handleRepClientEvent()`

  The local environment is now a replica.

- `EventHandler.handleRepLocalSiteRemovedEvent()`

  The local Replication Manager site has been removed from the group.

- `EventHandler.handleRepMasterEvent()`

  The local environment is now a master.

- `EventHandler.handleRepNewMasterEvent()`

  An election was held and a new environment was made a master. However, the current environment is not the master. This event exists so that you can cause your code to take some unique action in the event that the replication groups switches masters.

- `EventHandler.handleRepPermFailedEvent()`

  The Replication Manager did not receive enough acknowledgements to ensure the transaction's durability within the replicationg group. The Replication Manager has therefore flushed the transaction to the master's local disk for storage.

  How the Replication Manager knows whether the acknowledgements it has received is determined by the acknowledgement policy you have set for your applicaton. See Identifying Permanent Message Policies for more information.

- `EventHandler.handleRepSiteAddedEvent()`

  A new Replication Manager site has joined the replication group.

- `EventHandler.handleRepSiteRemovedEvent()`

  An existing Replication Manager site has been removed from the replication group.

- `EventHandler.handleRepStartupDoneEvent()`

  The replica has completed startup synchronization and is now processing log records received from the master.

For an example of how to use this callback, see Determining State

Prev | Up | Next
Permanent Message Handling | Home | Chapter 2. Transactional Application