Represents a transaction used to receive the message from the queueing infrastructure.
Inheritance: ContextBag
Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the error context.
        /// </summary>
        public ErrorContext(Exception exception, Dictionary<string, string> headers, string transportMessageId, byte[] body, TransportTransaction transportTransaction, int immediateProcessingFailures)
        {
            Exception = exception;
            TransportTransaction = transportTransaction;
            ImmediateProcessingFailures = immediateProcessingFailures;

            Message = new IncomingMessage(transportMessageId, headers, body);

            DelayedDeliveriesPerformed = Message.GetDelayedDeliveriesPerformed();
        }
 public Task<CompletableSynchronizedStorageSession> TryAdapt(TransportTransaction transportTransaction, ContextBag context)
 {
     Transaction ambientTransaction;
     if (transportTransaction.TryGet(out ambientTransaction))
     {
         var session = context.GetAsyncSession();
         CompletableSynchronizedStorageSession completableSynchronizedStorageSession = new RavenDBSynchronizedStorageSession(session, true);
         return Task.FromResult(completableSynchronizedStorageSession);
     }
     return EmptyResult;
 }
Ejemplo n.º 3
0
 public Task<CompletableSynchronizedStorageSession> TryAdapt(TransportTransaction transportTransaction, ContextBag context)
 {
     SqlConnection existingSqlConnection;
     SqlTransaction existingSqlTransaction;
     //SQL server transport in native TX mode
     if (transportTransaction.TryGet(out existingSqlConnection) && transportTransaction.TryGet(out existingSqlTransaction))
     {
         CompletableSynchronizedStorageSession session = new StorageSession(existingSqlConnection, existingSqlTransaction, false);
         return Task.FromResult(session);
     }
     //Other modes handled by creating a new session.
     return EmptyResult;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the context.
        /// </summary>
        /// <param name="messageId">Native message id.</param>
        /// <param name="headers">The message headers.</param>
        /// <param name="body">The message body.</param>
        /// <param name="transportTransaction">Transaction (along with connection if applicable) used to receive the message.</param>
        /// <param name="receiveCancellationTokenSource">
        /// Allows the pipeline to flag that it has been aborted and the receive operation should be rolled back.
        /// It also allows the transport to communicate to the pipeline to abort if possible. Transports should check if the token
        /// has been aborted after invoking the pipeline and roll back the message accordingly.
        /// </param>
        /// <param name="context">Any context that the transport wants to be available on the pipeline.</param>
        public MessageContext(string messageId, Dictionary<string, string> headers, byte[] body, TransportTransaction transportTransaction, CancellationTokenSource receiveCancellationTokenSource, ContextBag context)
        {
            Guard.AgainstNullAndEmpty(nameof(messageId), messageId);
            Guard.AgainstNull(nameof(body), body);
            Guard.AgainstNull(nameof(headers), headers);
            Guard.AgainstNull(nameof(transportTransaction), transportTransaction);
            Guard.AgainstNull(nameof(receiveCancellationTokenSource), receiveCancellationTokenSource);
            Guard.AgainstNull(nameof(context), context);

            Headers = headers;
            Body = body;
            MessageId = messageId;
            Context = context;
            TransportTransaction = transportTransaction;
            ReceiveCancellationTokenSource = receiveCancellationTokenSource;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes the context.
        /// </summary>
        /// <param name="messageId">Native message id.</param>
        /// <param name="headers">The message headers.</param>
        /// <param name="body">The message body.</param>
        /// <param name="transportTransaction">Transaction (along with connection if applicable) used to receive the message.</param>
        /// <param name="receiveCancellationTokenSource">
        /// Allows the pipeline to flag that it has been aborted and the receive operation should be rolled back.
        /// It also allows the transport to communicate to the pipeline to abort if possible. Transports should check if the token
        /// has been aborted after invoking the pipeline and roll back the message accordingly.
        /// </param>
        /// <param name="context">A <see cref="ContextBag" /> which can be used to extend the current object.</param>
        public MessageContext(string messageId, Dictionary <string, string> headers, byte[] body, TransportTransaction transportTransaction, CancellationTokenSource receiveCancellationTokenSource, ContextBag context)
        {
            Guard.AgainstNullAndEmpty(nameof(messageId), messageId);
            Guard.AgainstNull(nameof(body), body);
            Guard.AgainstNull(nameof(headers), headers);
            Guard.AgainstNull(nameof(transportTransaction), transportTransaction);
            Guard.AgainstNull(nameof(receiveCancellationTokenSource), receiveCancellationTokenSource);
            Guard.AgainstNull(nameof(context), context);

            Headers                        = headers;
            Body                           = body;
            MessageId                      = messageId;
            Extensions                     = context;
            TransportTransaction           = transportTransaction;
            ReceiveCancellationTokenSource = receiveCancellationTokenSource;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes the error context.
        /// </summary>
        /// <param name="exception">The exception that caused the message processing failure.</param>
        /// <param name="headers">The message headers.</param>
        /// <param name="nativeMessageId">The native message ID.</param>
        /// <param name="body">The message body.</param>
        /// <param name="transportTransaction">Transaction (along with connection if applicable) used to receive the message.</param>
        /// <param name="immediateProcessingFailures">Number of failed immediate processing attempts.</param>
        /// <param name="context">A <see cref="ReadOnlyContextBag" /> which can be used to extend the current object.</param>
        public ErrorContext(Exception exception, Dictionary <string, string> headers, string nativeMessageId, byte[] body, TransportTransaction transportTransaction, int immediateProcessingFailures, ReadOnlyContextBag context)
        {
            Guard.AgainstNull(nameof(exception), exception);
            Guard.AgainstNull(nameof(transportTransaction), transportTransaction);
            Guard.AgainstNegative(nameof(immediateProcessingFailures), immediateProcessingFailures);
            Guard.AgainstNull(nameof(context), context);

            Exception                   = exception;
            TransportTransaction        = transportTransaction;
            ImmediateProcessingFailures = immediateProcessingFailures;

            Message = new IncomingMessage(nativeMessageId, headers, body);

            DelayedDeliveriesPerformed = Message.GetDelayedDeliveriesPerformed();
            Extensions = context;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes the error context.
        /// </summary>
        public ErrorContext(Exception exception, Dictionary <string, string> headers, string transportMessageId, byte[] body, TransportTransaction transportTransaction, int immediateProcessingFailures)
        {
            Exception                   = exception;
            TransportTransaction        = transportTransaction;
            ImmediateProcessingFailures = immediateProcessingFailures;

            Message = new IncomingMessage(transportMessageId, headers, body);

            DelayedDeliveriesPerformed = Message.GetDelayedDeliveriesPerformed();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes the context.
        /// </summary>
        /// <param name="nativeMessageId">The native message ID.</param>
        /// <param name="headers">The message headers.</param>
        /// <param name="body">The message body.</param>
        /// <param name="transportTransaction">Transaction (along with connection if applicable) used to receive the message.</param>
        /// <param name="context">A <see cref="ContextBag" /> which can be used to extend the current object.</param>
        public MessageContext(string nativeMessageId, Dictionary <string, string> headers, byte[] body, TransportTransaction transportTransaction, ContextBag context)
        {
            Guard.AgainstNullAndEmpty(nameof(nativeMessageId), nativeMessageId);
            Guard.AgainstNull(nameof(body), body);
            Guard.AgainstNull(nameof(headers), headers);
            Guard.AgainstNull(nameof(transportTransaction), transportTransaction);
            Guard.AgainstNull(nameof(context), context);

            Headers              = headers;
            Body                 = body;
            NativeMessageId      = nativeMessageId;
            Extensions           = context;
            TransportTransaction = transportTransaction;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes the error context.
 /// </summary>
 /// <param name="exception">The exception that caused the message processing failure.</param>
 /// <param name="headers">The message headers.</param>
 /// <param name="transportMessageId">Native message id.</param>
 /// <param name="body">The message body.</param>
 /// <param name="transportTransaction">Transaction (along with connection if applicable) used to receive the message.</param>
 /// <param name="immediateProcessingFailures">Number of failed immediate processing attempts.</param>
 public ErrorContext(Exception exception, Dictionary <string, string> headers, string transportMessageId, byte[] body, TransportTransaction transportTransaction, int immediateProcessingFailures)
     : this(exception, headers, transportMessageId, body, transportTransaction, immediateProcessingFailures, emptyBag)
 {
 }