Skip to content

Commit

Permalink
0005108: Failed to route beanshell event from conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Oct 22, 2021
1 parent ff5b853 commit 0a42448
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -35,6 +35,7 @@
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.common.TableConstants;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.ext.ISymmetricEngineAware;
import org.jumpmind.symmetric.io.data.CsvData;
Expand Down Expand Up @@ -196,7 +197,6 @@ protected void handleWinnerForNewerCaptureWins(ISqlTransaction transaction, CsvD
Data data = new Data(tableName, csvData.getDataEventType(),
csvData.getCsvData(CsvData.ROW_DATA), csvData.getCsvData(CsvData.PK_DATA), hist,
csvData.getAttribute(CsvData.ATTRIBUTE_CHANNEL_ID), null, csvData.getAttribute(CsvData.ATTRIBUTE_SOURCE_NODE_ID));
data.setTableName(tableName);
data.setOldData(csvData.getCsvData(CsvData.OLD_DATA));
data.setPreRouted(true);
data.setCreateTime(csvData.getAttribute(CsvData.ATTRIBUTE_CREATE_TIME));
Expand All @@ -205,15 +205,17 @@ protected void handleWinnerForNewerCaptureWins(ISqlTransaction transaction, CsvD
String channelId = csvData.getAttribute(CsvData.ATTRIBUTE_CHANNEL_ID);
if (channelId != null && !channelId.equals(Constants.CHANNEL_RELOAD)) {
String pkCsvData = CsvUtils.escapeCsvData(getPkCsvData(csvData, hist));
if (pkCsvData != null) {
String nodeTableName = TableConstants.getTableName(parameterService.getTablePrefix(), TableConstants.SYM_NODE);
List<TriggerHistory> nodeHists = engine.getTriggerRouterService().getActiveTriggerHistories(nodeTableName);
if (nodeHists != null && nodeHists.size() > 0 && pkCsvData != null) {
String sourceNodeId = csvData.getAttribute(CsvData.ATTRIBUTE_SOURCE_NODE_ID);
long createTime = data.getCreateTime() != null ? data.getCreateTime().getTime() : 0;
String script = "if (context != void && context != null) { " +
"engine.getDataService().sendNewerDataToNode(context.findTransaction(), SOURCE_NODE_ID, \"" +
tableName + "\", " + pkCsvData + ", new Date(" +
createTime +"L), \"" + sourceNodeId + "\"); }";
Data scriptData = new Data(tableName, DataEventType.BSH,
CsvUtils.escapeCsvData(script), null, hist, Constants.CHANNEL_RELOAD, null, null);
Data scriptData = new Data(nodeTableName, DataEventType.BSH,
CsvUtils.escapeCsvData(script), null, nodeHists.get(0), Constants.CHANNEL_RELOAD, null, null);
scriptData.setSourceNodeId(sourceNodeId);
engine.getDataService().insertData(transaction, scriptData);
}
Expand Down

0 comments on commit 0a42448

Please sign in to comment.