private void clearRecords() { atomfeedTransactionManager.executeWithTransaction( new AFTransactionWorkWithoutResult() { @Override protected void doInTransaction() { try { Statement statement = connectionProvider.getConnection().createStatement(); String event_records_table = JdbcUtils.getTableName(getProperty("atomdb.default_schema"), "event_records"); statement.execute(String.format("delete from %s", event_records_table)); String event_records_marker_table = JdbcUtils.getTableName( getProperty("atomdb.default_schema"), "event_records_offset_marker"); statement.execute(String.format("delete from %s", event_records_marker_table)); String chunking_history_table = JdbcUtils.getTableName(getProperty("atomdb.default_schema"), "chunking_history"); statement.execute(String.format("delete from %s", chunking_history_table)); statement.close(); } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException("Error occurred while trying to clear records.", e); } } @Override public PropagationDefinition getTxPropagationDefinition() { return PropagationDefinition.PROPAGATION_REQUIRED; } }); }
private void addChunkingHistory(final Integer chunkSize, final Integer startId) throws SQLException { atomfeedTransactionManager.executeWithTransaction( new AFTransactionWorkWithoutResult() { @Override protected void doInTransaction() { try { Statement statement = connectionProvider.getConnection().createStatement(); String tableName = JdbcUtils.getTableName(getProperty("atomdb.default_schema"), "chunking_history"); statement.execute( String.format( "insert into %s (chunk_length, start) values (%d, %d)", tableName, chunkSize, startId)); statement.close(); } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException("Error occurred while trying to clear records.", e); } } @Override public PropagationDefinition getTxPropagationDefinition() { return PropagationDefinition.PROPAGATION_REQUIRED; } }); }