For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Data Source Operation Handler

Implement the DataSourceOperationHandler interface to convert GoldenGate source updates into GridGain cache operations, and configure it in Spring XML.

The DataSourceOperationHandler interface allows you to convert updates from the source database to a cache object and perform cache operations. DataSourceOperationHandler interface should be implemented by the user.

Java
/**
 * A function that allows applications to perform operations on updates from
 * DataBase and store them to cache. The callback will be invoked on each
 * operation such as insert, update, delete rows, etc.
 */
public interface DataSourceOperationHandler {
    /**
     * Init method. This method will be invoked before the handler starts
     * to receive updates from database.
     *
     * @param ignite Ignite instance.
     */
    public void init(Ignite ignite);

    /**
     * Handle single operation update. This method invoked when
     * {@link GridGainHandler#setMode(String)} in "op" mode.
     *
     * @param dsOp An operation on a data source, containing the current
     *      column values (after the operation occurred) and optionally
     *      the "before" values (before the operation occurred). An operation
     *      can in general be a database operation such as
     *      insert/update/delete or a primary-key update.
     * @param opCtx Operation context contains information about operations.
     */
    public void handleOperation(DsOperation dsOp, OperationContext opCtx);

    /**
     * Handle transaction update. This method invoked when
     * {@link GridGainHandler#setMode(String)} in "tx" mode.
     *
     * @param tx Data source transaction. This object contains info about
     *      whole transaction: changed rows, value, type and etc.
     * @param opCtx Operation context contains information about operations.
     */
    public void handleTransaction(DsTransaction tx, OperationContext opCtx);
}

The init() method is invoked before the handler starts to receive any updates from the database. This is a good place to create caches, check configurations, etc. On each update from the database, GridGain Handler will invoke the handleOperation() or handleTransaction() method. If GridGain Handler is working in tx mode, handleTransaction will be invoked. Otherwise, handleOperation will be invoked. Implementation of these methods can be used by any Ignite APIs: cache operations, compute, messaging, etc. Here is an example pseudo-code implementation:

The Handler should be configured in Spring XML configuration file that is used for starting GridGain Handler.

You also need to set the operationHandlerBeanName parameter for GridGainHandler in dirprm/gridgain.props.

This page is: Copyright © 2026 MariaDB. All rights reserved.

Last updated

Was this helpful?