Skip to main content

Replication agent extension tutorial

Tutorial for extending the replication agent to log replication events

Abstract

This tutorial describes how to run an example that demonstrates one possible use of the user-defined extensions for replication by providing detailed logging of the replication subsystem

This tutorial describes how to run an example that demonstrates one possible use of the user-defined extensions for replication by providing detailed logging of the replication subsystem.

To exercise replication to monitor its behavior, compile ctrepluser.c with #define REPLUSER_LOGGING uncommented. This will enable code that calls a function to log a message to the file ctrepluser.log each time one of the callback functions is called. The sample code also tracks the number of calls made to each callback function using the #define REPLUSER_LOGGING logic discussed in replication logging.

Note

This is only one simple use of the callback extension. By reviewing the code in ctrepluser.c, you will be able to explore many alternate uses for this technology.

To begin the tutorial, we will execute some scripts to build the data on the source server and target server. With data on both servers, we can insert data and delete data in the table we built. We will connect to the source and watch the Replication Agent replicating data to the target server.

Figure 1. The Replication Agent replicates data to the target server
The Replication Agent replicates data to the target server