Exemplo n.º 1
0
        /// <summary>
        /// Establishes the idempotent context for the specified message context.
        /// </summary>
        /// <param name="idempotentSagaData">The idempotent saga data.</param>
        /// <param name="messageContext">The message context.</param>
        private void EstablishIdempotencyContextFor(IIdempotentSagaData idempotentSagaData, IMessageContext messageContext)
        {
            var id         = messageContext.RebusTransportMessageId;
            var serializer = backbone.SerializeMessages;

            log.Debug("Established idempotent saga context for: {0} (Handler: {1})", id, idempotentSagaData.GetType());

            var message = new Message()
            {
                Headers  = messageContext.Headers,
                Messages = new object[] { messageContext.CurrentMessage }
            };
            var serializedMessage = serializer.Serialize(message);

            var executionResults = new IdempotentSagaResults(id, serializedMessage, serializer.GetType());

            messageContext.Items[Headers.IdempotentSagaResults] = executionResults;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Re-sends stored side effects from an already handled message.
        /// </summary>
        /// <param name="handlingData">The handling data.</param>
        /// <param name="bus">The bus.</param>
        /// <param name="messageContext">The message context.</param>
        private void ResendStoredSideEffects(IBus bus, IdempotentSagaResults handlingData, IMessageContext messageContext)
        {
            log.Info("Replaying {0} side-effects relating to a previous idempotent handling of message: {1}.",
                     handlingData.SideEffects.Count, messageContext.RebusTransportMessageId);

            foreach (var item in handlingData.SideEffects)
            {
                var toSend = new TransportMessageToSend()
                {
                    Headers = item.Headers,
                    Body    = item.Message
                };

                foreach (var destination in item.Destinations)
                {
                    backbone.SendMessages.Send(destination, toSend, TransactionContext.Current);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Establishes the idempotent context for the specified message context.
        /// </summary>
        /// <param name="idempotentSagaData">The idempotent saga data.</param>
        /// <param name="messageContext">The message context.</param>
        private void EstablishIdempotencyContextFor(IIdempotentSagaData idempotentSagaData, IMessageContext messageContext)
        {
            var id = messageContext.RebusTransportMessageId;
            var serializer = backbone.SerializeMessages;

            log.Debug("Established idempotent saga context for: {0} (Handler: {1})", id, idempotentSagaData.GetType());

            var message = new Message()
            {
                Headers = messageContext.Headers,
                Messages = new object[] { messageContext.CurrentMessage }
            };
            var serializedMessage = serializer.Serialize(message);

            var executionResults = new IdempotentSagaResults(id, serializedMessage, serializer.GetType());
            messageContext.Items[Headers.IdempotentSagaResults] = executionResults;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Re-sends stored side effects from an already handled message.
        /// </summary>
        /// <param name="handlingData">The handling data.</param>
        /// <param name="bus">The bus.</param>
        /// <param name="messageContext">The message context.</param>
        private void ResendStoredSideEffects(IBus bus, IdempotentSagaResults handlingData, IMessageContext messageContext)
        {
            log.Info("Replaying {0} side-effects relating to a previous idempotent handling of message: {1}.", 
                handlingData.SideEffects.Count, messageContext.RebusTransportMessageId);

            foreach (var item in handlingData.SideEffects)
            {
                var toSend = new TransportMessageToSend()
                {
                    Headers = item.Headers,
                    Body = item.Message
                };

                foreach (var destination in item.Destinations)
                {
                    backbone.SendMessages.Send(destination, toSend, TransactionContext.Current);
                }
            }
        }