View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

How to Disable the SymmetricDS Triggers

Introduction

Sometimes there is a need to load in a database big volumes of data that do not need to be synchronized.

This happens for instance when historical data belonging to a store server yet to be deployed is loaded in a central server. That data does not need to be synchronized to any of the existing store servers, so capturing it and routing it (the routing process would result in that data being routed nowhere anyway) is a waste of resources.

When a data load like this is going to be performed, it should be done with the SymmetricDS triggers disabled. This way the changes will not be captured by the triggers, will not end up in sym_data and as a result they will not be routed.

The SymmetricDSTriggerHandler class

The SymmetricDSTriggerHandler class works like the TriggerHandler class, in the sense that it can be used to disable and reenable triggers. TriggerHandler is able to enable/disable the triggers defined as part of the Openbravo model, while SymmetricDSTriggerHandler enable/disable the triggers that SymmetricDS places on the synchronized tables.

To do this, the disable and enable methods must be used like this:

    try {
      SymmetricDSTriggerHandler.getInstance().disable();
      importStoreData();
    } catch (Exception e) {
      Log.error("Error while importing the store's data");
    } finally {
      SymmetricDSTriggerHandler.getInstance().enable();
    }

It is OF GREAT IMPORTANCE that the SymmetricDS triggers are reenabled before committing the changes. Not doing it would result in the SymmetricDS triggers being disabled outside the import process, which would result in rightful changes not being synchronized. Make sure to place the SymmetricDSTriggerHandler.getInstance().enable(); in a finally block, and to prevent committing the transaction before running it.

Retrieved from "http://wiki.openbravo.com/wiki/How_to_Disable_the_SymmetricDS_Triggers"

This page has been accessed 273 times. This page was last modified on 2 November 2016, at 09:02. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.