Skip to content

Commit

Permalink
Added a property to turn off the SKIP batch feature
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Oct 19, 2007
1 parent 60c1d25 commit 557469a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
Expand Up @@ -36,44 +36,48 @@

public class IncomingBatchService extends AbstractService implements IIncomingBatchService {

protected static final Log logger = LogFactory.getLog(IncomingBatchService.class);

protected String findIncomingBatchSql;

protected String findIncomingBatchHistorySql;

protected String insertIncomingBatchSql;
private static final Log logger = LogFactory.getLog(IncomingBatchService.class);

protected String updateIncomingBatchSql;
private String findIncomingBatchSql;

protected String insertIncomingBatchHistorySql;
private String findIncomingBatchHistorySql;

private String insertIncomingBatchSql;

private String updateIncomingBatchSql;

private String insertIncomingBatchHistorySql;

private boolean skipDuplicateBatches = true;

public IncomingBatch findIncomingBatch(String batchId, String clientId) {
try {
return (IncomingBatch) jdbcTemplate.queryForObject(findIncomingBatchSql, new Object[] {
batchId, clientId }, new IncomingBatchMapper());
return (IncomingBatch) jdbcTemplate.queryForObject(findIncomingBatchSql,
new Object[] { batchId, clientId }, new IncomingBatchMapper());
} catch (EmptyResultDataAccessException e) {
return null;
}
}

@SuppressWarnings("unchecked")
public List<IncomingBatchHistory> findIncomingBatchHistory(String batchId, String clientId) {
return (List<IncomingBatchHistory>) jdbcTemplate.query(findIncomingBatchHistorySql,
new Object[] { batchId, clientId }, new IncomingBatchHistoryMapper());
return (List<IncomingBatchHistory>) jdbcTemplate.query(findIncomingBatchHistorySql, new Object[] { batchId,
clientId }, new IncomingBatchHistoryMapper());
}

public boolean acquireIncomingBatch(IncomingBatch status) {
boolean okayToProcess = true;
try {
insertIncomingBatch(status);
} catch (DataIntegrityViolationException e) {
status.setRetry(true);
okayToProcess = updateIncomingBatch(status) > 0;
if (okayToProcess) {
logger.warn("Retrying batch " + status.getClientBatchId());
} else {
logger.warn("Skipping batch " + status.getClientBatchId());
if (skipDuplicateBatches) {
okayToProcess = updateIncomingBatch(status) > 0;
if (okayToProcess) {
logger.warn("Retrying batch " + status.getClientBatchId());
} else {
logger.warn("Skipping batch " + status.getClientBatchId());
}
}
}
return okayToProcess;
Expand All @@ -90,10 +94,9 @@ public int updateIncomingBatch(IncomingBatch status) {
}

public void insertIncomingBatchHistory(IncomingBatchHistory history) {
jdbcTemplate.update(insertIncomingBatchHistorySql, new Object[] { history.getBatchId(),
history.getClientId(), history.getStatus().toString(), history.getHostName(),
history.getStatementCount(), history.getFallbackInsertCount(),
history.getFallbackUpdateCount(), history.getMissingDeleteCount(),
jdbcTemplate.update(insertIncomingBatchHistorySql, new Object[] { history.getBatchId(), history.getClientId(),
history.getStatus().toString(), history.getHostName(), history.getStatementCount(),
history.getFallbackInsertCount(), history.getFallbackUpdateCount(), history.getMissingDeleteCount(),
history.getFailedRowNumber(), history.getStartTime(), history.getEndTime() });
}

Expand Down Expand Up @@ -123,7 +126,7 @@ public Object mapRow(ResultSet rs, int num) throws SQLException {
return history;
}
}

public void setFindIncomingBatchHistorySql(String findIncomingBatchHistorySql) {
this.findIncomingBatchHistorySql = findIncomingBatchHistorySql;
}
Expand All @@ -144,4 +147,8 @@ public void setUpdateIncomingBatchSql(String updateIncomingBatchSql) {
this.updateIncomingBatchSql = updateIncomingBatchSql;
}

public void setSkipDuplicateBatches(boolean skipDuplicateBatchesEnabled) {
this.skipDuplicateBatches = skipDuplicateBatchesEnabled;
}

}
3 changes: 2 additions & 1 deletion symmetric/src/main/resources/symmetric-properties.xml
Expand Up @@ -27,7 +27,8 @@
<prop key="symmetric.auto.config.database">true</prop>
<prop key="symmetric.http.download.rate.kb">-1</prop>
<prop key="symmetric.http.concurrent.workers.max">20</prop>
<prop key="symmetric.runtime.max.outgoing.batches.to.process">60</prop>
<prop key="symmetric.runtime.outgoing.batches.max.to.process">60</prop>
<prop key="symmetric.runtime.incoming.batches.skip.duplicates">true</prop>
<prop key="symmetric.runtime.engine.name">Default</prop>
<prop key="symmetric.runtime.schema.version">?</prop>
<prop key="symmetric.runtime.trigger.prefix"></prop>
Expand Down
3 changes: 2 additions & 1 deletion symmetric/src/main/resources/symmetric-services.xml
Expand Up @@ -183,7 +183,7 @@
<property name="dataSource" ref="dataSource" />
<property name="queryTimeout" value="${db.sql.query.timeout.seconds}" />
<property name="maxRows"
value="${symmetric.runtime.max.outgoing.batches.to.process}" />
value="${symmetric.runtime.outgoing.batches.max.to.process}" />
</bean>
</property>
<property name="initialLoadStatusSql">
Expand Down Expand Up @@ -302,6 +302,7 @@

<bean id="incomingBatchService" class="org.jumpmind.symmetric.service.impl.IncomingBatchService"
scope="singleton">
<property name="skipDuplicateBatches" value="${symmetric.runtime.incoming.batches.skip.duplicates}"/>
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="findIncomingBatchSql">
<value>
Expand Down

0 comments on commit 557469a

Please sign in to comment.