use of org.apache.synapse.message.store.impl.jdbc.util.Statement in project wso2-synapse by wso2.
the class ResequenceMessageStore method removeMessageStatement.
/**
* <p>
* Remove message statement.
* </p>
* <p>
* When re-sequenced we need to maintain the last processed id along with the removal. So that at an event the node
* crashes we know where to start from.
* </p>
* <p>
* <p>
* {@inheritDoc}
*/
@Override
protected List<Statement> removeMessageStatement(String msgId) {
Long messageSequenceId = sequenceIdMapper.remove(msgId);
String messageStoreName = this.getName();
if (messageSequenceId == null) {
log.error("The message with id " + msgId + " is not tracked within the memory.");
}
ArrayList<Statement> statements = new ArrayList<>();
final String deleteMessageStatement = "DELETE FROM " + getJdbcConfiguration().getTableName() + " WHERE msg_id=?";
final String insertLastProcessIdStatement = "INSERT INTO " + ResequenceMessageStoreConstants.LAST_PROCESS_ID_TABLE_NAME + " (statement,seq_id) VALUES (?,?) ON DUPLICATE KEY UPDATE seq_id = ?";
Statement sequenceIdUpdateStatement = new Statement(insertLastProcessIdStatement) {
@Override
public List<Map> getResult(ResultSet resultSet) throws SQLException {
throw new UnsupportedOperationException();
}
};
Statement deleteMessage = new Statement(deleteMessageStatement) {
@Override
public List<Map> getResult(ResultSet resultSet) throws SQLException {
throw new UnsupportedOperationException();
}
};
deleteMessage.addParameter(msgId);
sequenceIdUpdateStatement.addParameter(messageStoreName);
sequenceIdUpdateStatement.addParameter(messageSequenceId);
sequenceIdUpdateStatement.addParameter(messageSequenceId);
statements.add(deleteMessage);
statements.add(sequenceIdUpdateStatement);
if (log.isDebugEnabled()) {
log.debug("Removing message with id:" + msgId + " and last process id:" + messageSequenceId);
}
return statements;
}
Aggregations