I am using 2.1.2, i developed a IDataLoaderFilter, my requirement is to redirect to a diferent table, so I neet to get the connection in which symmetric is replicating, i get connection like this but I think this is wrong:
@Override
public boolean filterUpdate(IDataLoaderContext context, String[] columnValues, String[] keyValues) {
Map<String, DataSource> beans = appContext.getBeansOfType(DataSource.class);
DataSource ds = (DataSource) beans.get("dataSource");
Connection con = null;
Statement st = null;
ResultSet rs = null;
try {
con = ds.getConnection();
...
I think that the IDataLoader is called in the replicating transaction, and the way i get the connection is wrong because i get a new connection, not the same connection of the replicating transaction.
What is the right way to get the replicating connection so that my DML's are done in the same replicating transaction?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"If work needs to occur on the target database itself within the same database transaction that the load is taking place in, then the IDataLoaderContext should be used to access a JdbcTemplate. The JdbcTemplate contains the connection that is being used for the data load."
I am using 2.1.2, i developed a IDataLoaderFilter, my requirement is to redirect to a diferent table, so I neet to get the connection in which symmetric is replicating, i get connection like this but I think this is wrong:
...
I think that the IDataLoader is called in the replicating transaction, and the way i get the connection is wrong because i get a new connection, not the same connection of the replicating transaction.
What is the right way to get the replicating connection so that my DML's are done in the same replicating transaction?
"If work needs to occur on the target database itself within the same database transaction that the load is taking place in, then the IDataLoaderContext should be used to access a JdbcTemplate. The JdbcTemplate contains the connection that is being used for the data load."
http://www.symmetricds.org/doc/2.5/javadoc/org/jumpmind/symmetric/load/IDataLoaderFilter.html
Last edit: Austin Brougher 2013-04-08
Great, many thanks!