コード例 #1
0
 /// <inheritdoc />
 public void Ack()
 {
     if (_messageQueueTransaction?.Status == MessageQueueTransactionStatus.Pending)
     {
         _messageQueueTransaction.Commit();
     }
 }
コード例 #2
0
        public void Send(IMessage msg, MessageQueueTransactionType transactionType)
        {
            switch (transactionType)
            {
            case MessageQueueTransactionType.Single:
                using (IMessageQueueTransaction tx = provider.CreateMessageQueueTransaction())
                {
                    try
                    {
                        Send(msg, tx);
                        tx.Commit();
                    }
                    catch (Exception e)
                    {
                        tx.Abort();
                        throw new MonoMessagingException(e.Message, e);
                    }
                }
                break;

            case MessageQueueTransactionType.None:
                Send(msg);
                break;

            case MessageQueueTransactionType.Automatic:
                throw new NotSupportedException("Automatic transaction types not supported");
            }
        }
コード例 #3
0
        private ITransactionalMessage CreateTransactionalMessage(Stream stream, IMessageQueueTransaction messageQueueTransaction)
        {
            stream.Position = 0;

            using (var streamReader = new StreamReader(stream, Encoding.UTF8))
            {
                var queueMessage = streamReader.ReadToEnd().DeserializeFromJson <QueueMessage>();

                if (queueMessage != null)
                {
                    Logger.Debug("Message received {QueueName} {Type} {%Message}", Name, queueMessage?.MessageType?.FullName, queueMessage?.MessageBody);
                }

                if (queueMessage == null)
                {
                    messageQueueTransaction?.Commit();
                    messageQueueTransaction?.Dispose();
                    messageQueueTransaction = null;
                }

                return(new TransactionalMessage(queueMessage, messageQueueTransaction));
            }
        }
コード例 #4
0
 public void Commit()
 {
     delegateTx.Commit();
 }