public IEnumerable <MessageToReset> Handle(FindMessagesToResetByHeartBeatQuery query) { var results = new List <MessageToReset>(); if (query.Cancellation.IsCancellationRequested) { return(results); } using (var connection = _dbConnectionFactory.Create()) { connection.Open(); //before executing a query, double check that we aren't stopping //otherwise, there is a chance that the tables no longer exist in memory mode if (query.Cancellation.IsCancellationRequested) { return(results); } using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.GetHeartBeatExpiredMessageIds); using (var reader = command.ExecuteReader()) { while (reader.Read()) { if (query.Cancellation.IsCancellationRequested) { break; } var headers = _readColumn.ReadAsByteArray(CommandStringTypes.GetHeartBeatExpiredMessageIds, 2, reader); if (headers != null) { var allheaders = _serialization.InternalSerializer.ConvertBytesTo <IDictionary <string, object> >(headers); results.Add(new MessageToReset(_readColumn.ReadAsInt64(CommandStringTypes.GetHeartBeatExpiredMessageIds, 0, reader), _readColumn.ReadAsDateTime(CommandStringTypes.GetHeartBeatExpiredMessageIds, 1, reader), new ReadOnlyDictionary <string, object>(allheaders))); } else { results.Add(new MessageToReset(_readColumn.ReadAsInt64(CommandStringTypes.GetHeartBeatExpiredMessageIds, 0, reader), _readColumn.ReadAsDateTime(CommandStringTypes.GetHeartBeatExpiredMessageIds, 1, reader), null)); } } } } } return(results); }
public long Handle(GetErrorCountQuery query) { using (var connection = _connectionFactory.Create()) { connection.Open(); using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.GetErrorCount); using (var reader = command.ExecuteReader()) { if (reader.Read()) { return(_readColumn.ReadAsInt64(CommandStringTypes.GetErrorCount, 0, reader)); } } } } return(0); }
public IEnumerable <long> Handle(FindExpiredMessagesToDeleteQuery query) { if (query.Cancellation.IsCancellationRequested) { return(Enumerable.Empty <long>()); } var results = new List <long>(); var commandType = _options.Value.EnableStatus ? CommandStringTypes.FindExpiredRecordsWithStatusToDelete : CommandStringTypes.FindExpiredRecordsToDelete; using (var connection = _dbConnectionFactory.Create()) { connection.Open(); //before executing a query, double check that we aren't stopping //otherwise, there is a chance that the tables no longer exist in memory mode if (query.Cancellation.IsCancellationRequested) { return(Enumerable.Empty <long>()); } using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, commandType); using (var reader = command.ExecuteReader()) { while (reader.Read()) { if (query.Cancellation.IsCancellationRequested) { break; } results.Add(_readColumn.ReadAsInt64(commandType, 0, reader)); } } } } return(results); }
public IEnumerable <MessageToReset> Handle(FindMessagesToResetByHeartBeatQuery query) { var results = new List <MessageToReset>(); if (query.Cancellation.IsCancellationRequested) { return(results); } using (var connection = _dbConnectionFactory.Create()) { connection.Open(); //before executing a query, double check that we aren't stopping //otherwise, there is a chance that the tables no longer exist in memory mode if (query.Cancellation.IsCancellationRequested) { return(results); } using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.GetHeartBeatExpiredMessageIds); using (var reader = command.ExecuteReader()) { while (reader.Read()) { if (query.Cancellation.IsCancellationRequested) { break; } results.Add(new MessageToReset(_readColumn.ReadAsInt64(CommandStringTypes.GetHeartBeatExpiredMessageIds, 0, reader), _readColumn.ReadAsDateTime(CommandStringTypes.GetHeartBeatExpiredMessageIds, 1, reader))); } } } } return(results); }