コード例 #1
0
        public static void InsertLastProcessedMessage(
            UnitOfWork uow,
            long messageNumber,
            MessageEndpointName queueName)
        {
            MessageQueueProcessingDetailsRow d = new MessageQueueProcessingDetailsRow()
            {
                Id = Guid.NewGuid(),
                LastMessageNumber = messageNumber,
                QueueName         = queueName.Value,
                Version           = 0,
                UpdatedTimestamp  = DateTimeOffset.UtcNow
            };

            int rowsInserted = uow.DbConnection.Execute(
                InsertStatement,
                d,
                uow.Transaction);
        }
コード例 #2
0
        public static void UpdateLastProcessedMessage(
            UnitOfWork uow,
            MessageQueueProcessingDetailsRow queueDetails)
        {
            int rowCountUpdated = uow.DbConnection.Execute(
                MessageQueueProcessingDetailsUpdateQuery,
                new
            {
                Id = queueDetails.Id,
                LastMessageNumber     = queueDetails.LastMessageNumber,
                Version               = queueDetails.Version + 1,
                ExistingVersionNumber = queueDetails.Version,
                UpdatedTimestamp      = DateTimeOffset.UtcNow,
            },
                uow.Transaction);

            if (rowCountUpdated != 1)
            {
                throw new Exception("MessageQueueProcessingDetails: Concurrency Exception, (probably!)");
            }
        }