/// <inheritdoc /> public long Handle(DeleteTransactionalMessageCommand command) { var connection = command.MessageContext.Get(_headers.Connection); using (var commandSql = connection.CreateCommand()) { //delete the meta data record _prepareCommand.Handle(new DeleteMessageCommand(command.QueueId), commandSql, CommandStringTypes.DeleteFromMetaData); commandSql.ExecuteNonQuery(); //delete the message body _prepareCommand.Handle(new DeleteMessageCommand(command.QueueId), commandSql, CommandStringTypes.DeleteFromQueue); commandSql.ExecuteNonQuery(); //delete any error tracking information _prepareCommand.Handle(new DeleteMessageCommand(command.QueueId), commandSql, CommandStringTypes.DeleteFromErrorTracking); commandSql.ExecuteNonQuery(); //delete status record if (!_options.Value.EnableStatusTable) { return(1); } _prepareCommand.Handle(new DeleteMessageCommand(command.QueueId), commandSql, CommandStringTypes.DeleteFromStatus); commandSql.ExecuteNonQuery(); return(1); } }
/// <inheritdoc /> public QueueRemoveResult Handle(DeleteQueueTablesCommand inputCommand) { using (var connection = _dbConnectionFactory.Create()) { connection.Open(); using (var trans = _transactionFactory.Create(connection).BeginTransaction()) { foreach (var table in _tableNameHelper.Tables) { var delete = _tableExists.Handle( new GetTableExistsTransactionQuery(connection, trans, table)); if (!delete) { continue; } using (var commandSql = connection.CreateCommand()) { commandSql.Transaction = trans; _prepareDeleteTable.Handle(new DeleteTableCommand(table), commandSql, CommandStringTypes.DeleteTable); commandSql.ExecuteNonQuery(); } } trans.Commit(); return(new QueueRemoveResult(QueueRemoveStatus.Success)); } } }
private void SaveConfiguration(IDbConnection conn, IDbTransaction trans) { using (var commandSql = conn.CreateCommand()) { commandSql.Transaction = trans; _prepareSaveConfigurationCommand.Handle(new SaveQueueConfigurationCommand(_options.ConvertToBytes()), commandSql, CommandStringTypes.SaveConfiguration); commandSql.ExecuteNonQuery(); } }
/// <inheritdoc /> public void Handle(SetStatusTableStatusTransactionCommand command) { using ( var commandSqlUpdateStatusRecord = command.Connection.CreateCommand()) { commandSqlUpdateStatusRecord.Transaction = command.Transaction; _prepareCommand.Handle(command, commandSqlUpdateStatusRecord, CommandStringTypes.UpdateStatusRecord); commandSqlUpdateStatusRecord.ExecuteNonQuery(); } }
/// <inheritdoc /> public void Handle(DeleteMetaDataCommand command) { using ( var commandSqlDeleteMetaData = command.Connection.CreateCommand()) { _prepareCommand.Handle(command, commandSqlDeleteMetaData, CommandStringTypes.DeleteFromMetaData); commandSqlDeleteMetaData.Transaction = command.Transaction; commandSqlDeleteMetaData.ExecuteNonQuery(); } }
/// <inheritdoc /> public long Handle(DeleteMessageCommand <long> command) { using (var connection = _dbConnectionFactory.Create()) { connection.Open(); using (var trans = _transactionFactory.Create(connection).BeginTransaction()) { using (var commandSql = connection.CreateCommand()) { commandSql.Transaction = trans; //delete the meta data record _prepareCommand.Handle(command, commandSql, CommandStringTypes.DeleteFromMetaData); commandSql.ExecuteNonQuery(); //delete the message body _prepareCommand.Handle(command, commandSql, CommandStringTypes.DeleteFromQueue); commandSql.ExecuteNonQuery(); //delete any error tracking information _prepareCommand.Handle(command, commandSql, CommandStringTypes.DeleteFromErrorTracking); commandSql.ExecuteNonQuery(); _prepareCommand.Handle(command, commandSql, CommandStringTypes.DeleteFromMetaDataErrors); commandSql.ExecuteNonQuery(); //delete status record if (!_options.Value.EnableStatusTable) { trans.Commit(); return(1); } _prepareCommand.Handle(command, commandSql, CommandStringTypes.DeleteFromStatus); commandSql.ExecuteNonQuery(); trans.Commit(); return(1); } } } }
public void Handle(SetStatusTableStatusCommand command) { using (var connection = _dbConnectionFactory.Create()) { connection.Open(); using (var commandSql = connection.CreateCommand()) { _prepareCommand.Handle(command, commandSql, CommandStringTypes.UpdateStatusRecord); commandSql.ExecuteNonQuery(); } } }
/// <inheritdoc /> public void Handle(DeleteStatusTableStatusCommand <long> command) { using (var connection = _dbConnectionFactory.Create()) { connection.Open(); using (var commandSql = connection.CreateCommand()) { _prepareCommand.Handle(command, commandSql, CommandStringTypes.DeleteFromStatus); commandSql.ExecuteNonQuery(); } } }
/// <inheritdoc /> public void Handle(MoveRecordToErrorQueueCommand <long> command) { if (_options.Value.EnableHoldTransactionUntilMessageCommitted) { HandleForTransaction(command); } else { using (var conn = _dbConnectionFactory.Create()) { conn.Open(); using (var trans = _transactionFactory.Create(conn).BeginTransaction()) { using (var commandSql = conn.CreateCommand()) { commandSql.Transaction = trans; _prepareCommand.Handle(command, commandSql, CommandStringTypes.MoveToErrorQueue); var iCount = commandSql.ExecuteNonQuery(); if (iCount != 1) { return; } //the record is now in the error queue, remove it from the main queue _deleteMetaCommandHandler.Handle(new DeleteMetaDataCommand(command.QueueId, conn, trans)); if (!_options.Value.EnableStatusTable) { trans.Commit(); return; } //update the status record _setStatusCommandHandler.Handle(new SetStatusTableStatusTransactionCommand(command.QueueId, conn, QueueStatuses.Error, trans)); } trans.Commit(); } } } }
public void Handle(SetErrorCountCommand command) { using (var connection = _dbConnectionFactory.Create()) { connection.Open(); using (var commandSql = connection.CreateCommand()) { var commandType = _queryHandler.Handle(new GetErrorRecordExistsQuery(command.ExceptionType, command.QueueId)) ? CommandStringTypes.UpdateErrorCount : CommandStringTypes.InsertErrorCount; _prepareCommand.Handle(command, commandSql, commandType); commandSql.ExecuteNonQuery(); } } }
/// <inheritdoc /> public QueueCreationResult Handle(CreateJobTablesCommand <ITable> command) { using (var conn = _dbConnectionFactory.Create()) { conn.Open(); using (var trans = _transactionFactory.Create(conn).BeginTransaction()) { using (var commandSql = conn.CreateCommand()) { commandSql.Transaction = trans; _prepareCommandHandler.Handle(command, commandSql, CommandStringTypes.CreateJobTables); commandSql.ExecuteNonQuery(); } trans.Commit(); } } return(new QueueCreationResult(QueueCreationStatus.Success)); }
public QueueCreationResult Handle(CreateQueueTablesAndSaveConfigurationCommand <ITable> command) { using (var conn = _connectionFactory.Create()) { conn.Open(); using (var trans = _transactionFactory.Create(conn).BeginTransaction()) { using (var commandSql = conn.CreateCommand()) { commandSql.Transaction = trans; _prepareCommand.Handle(command, commandSql, CommandStringTypes.CreateQueueTables); commandSql.ExecuteNonQuery(); } //save the configuration SaveConfiguration(conn, trans); trans.Commit(); } } return(new QueueCreationResult(QueueCreationStatus.Success)); }
public long Handle(ResetHeartBeatCommand <long> inputCommand) { using (var connection = _connectionFactory.Create()) { connection.Open(); using (var trans = _transactionFactory.Create(connection).BeginTransaction()) { using (var command = connection.CreateCommand()) { command.Transaction = trans; _prepareCommand.Handle(inputCommand, command, CommandStringTypes.ResetHeartbeat); var result = command.ExecuteNonQuery(); if (result > 0) { trans.Commit(); } return(result); } } } }