當前位置: 首頁>>代碼示例>>C#>>正文


C# NServiceBus.TransportMessage類代碼示例

本文整理匯總了C#中NServiceBus.TransportMessage的典型用法代碼示例。如果您正苦於以下問題:C# TransportMessage類的具體用法?C# TransportMessage怎麽用?C# TransportMessage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TransportMessage類屬於NServiceBus命名空間,在下文中一共展示了TransportMessage類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateExistingMessage

        void UpdateExistingMessage(IDocumentSession session, string id, TransportMessage message)
        {
            var failedMessage = session.Load<Message>(id);
            
            var timeOfFailure = DateTimeExtensions.ToUtcDateTime(message.Headers["NServiceBus.TimeOfFailure"]);

            if (failedMessage.FailureDetails.TimeOfFailure == timeOfFailure)
            {
                return;
            }

            if (failedMessage.Status == MessageStatus.Successful && timeOfFailure > failedMessage.ProcessedAt)
            {
                throw new InvalidOperationException("A message can't first be processed successfully and then fail, Id: " + failedMessage.Id);
            }

            if (failedMessage.Status == MessageStatus.Successful)
            {
                failedMessage.FailureDetails = new FailureDetails(message);
            }
            else
            {
                failedMessage.Status = MessageStatus.RepeatedFailure;

                failedMessage.FailureDetails.RegisterException(message);
            }

            session.SaveChanges();
        }
開發者ID:raelyard,項目名稱:ServiceBus.Management,代碼行數:29,代碼來源:ErrorImportSatellite.cs

示例2: MutateIncoming

 public void MutateIncoming(TransportMessage transportMessage)
 {
     string bodyAsString = Encoding.UTF8
         .GetString(transportMessage.Body);
     Console.WriteLine("Serialized Message Body:");
     Console.WriteLine(bodyAsString);
 }
開發者ID:cdnico,項目名稱:docs.particular.net,代碼行數:7,代碼來源:MessageBodyWriter.cs

示例3: Handle

        public bool Handle(TransportMessage message)
        {
            using (var session = Store.OpenSession())
            {
                session.Advanced.UseOptimisticConcurrency = true;

                var failedMessage = new Message(message)
                    {
                        FailureDetails = new FailureDetails(message),
                        Status = MessageStatus.Failed,
                        ReplyToAddress = message.ReplyToAddress.ToString()
                    };

                try
                {
                    session.Store(failedMessage);

                    session.SaveChanges();
                }
                catch (ConcurrencyException) //there is already a message in the store with the same id
                {
                    session.Advanced.Clear();
                    UpdateExistingMessage(session, failedMessage.Id, message);
                }
            }

            Forwarder.Send(message, Settings.ErrorLogQueue);

            return true;
        }
開發者ID:raelyard,項目名稱:ServiceBus.Management,代碼行數:30,代碼來源:ErrorImportSatellite.cs

示例4: Handle

        public bool Handle(TransportMessage message)
        {
            using (var session = Store.OpenSession())
            {
                session.Advanced.UseOptimisticConcurrency = true;

                var auditMessage = new Message(message);

                auditMessage.MarkAsSuccessful(message);

                try
                {
                    session.Store(auditMessage);

                    session.SaveChanges();
                }
                catch (ConcurrencyException)
                {
                    session.Advanced.Clear();
                    UpdateExistingMessage(session,auditMessage.Id, message);
                }
            }

            return true;
        }
開發者ID:roycornelissen,項目名稱:ServiceControl,代碼行數:25,代碼來源:AuditMessageImportSatellite.cs

示例5: MutateOutgoing

        public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage)
        {
            var headers = transportMessage.Headers;
            if (headers.ContainsKey(Constants.Headers.Keys.Originator)) return;

            headers.Add(Constants.Headers.Keys.Originator, Source);
        }
開發者ID:jmeckley,項目名稱:MessageMutators,代碼行數:7,代碼來源:IncludeMetadataMessageMutator.cs

示例6: MutateIncoming

 public void MutateIncoming(TransportMessage transportMessage)
 {
     string bodyAsString = Encoding.UTF8
         .GetString(transportMessage.Body);
     log.Info("Serialized Message Body:");
     log.Info(bodyAsString);
 }
開發者ID:odelljl,項目名稱:docs.particular.net,代碼行數:7,代碼來源:MessageBodyWriter.cs

示例7: With_ProcessingEndpoint_header_should_return_processing_endpoint

 public void With_ProcessingEndpoint_header_should_return_processing_endpoint()
 {
     var message = new TransportMessage(Guid.Empty.ToString(), new Dictionary<string, string>
                                                               {
                                                                   { Headers.ProcessingEndpoint ,"TheEndpoint"}
                                                               });
     Assert.AreEqual("TheEndpoint",message.ProcessingEndpointName());
 }
開發者ID:AlexRhees,項目名稱:ServiceControl,代碼行數:8,代碼來源:TransportMessageExtensionsTests.cs

示例8: With_ReplyToAddress_should_return_ReplyToAddress

 public void With_ReplyToAddress_should_return_ReplyToAddress()
 {
     var message = new TransportMessage
                   {
                       ReplyToAddress = new Address("TheEndpoint", "")
                   };
     Assert.AreEqual("TheEndpoint",message.ProcessingEndpointName());
 }
開發者ID:AlexRhees,項目名稱:ServiceControl,代碼行數:8,代碼來源:TransportMessageExtensionsTests.cs

示例9: With_FailedQ_header_should_return_FailedQ

 public void With_FailedQ_header_should_return_FailedQ()
 {
     var message = new TransportMessage(Guid.Empty.ToString(), new Dictionary<string, string>
                                                               {
                                                                   { "NServiceBus.FailedQ" ,"TheEndpoint"}
                                                               });
     Assert.AreEqual("TheEndpoint",message.ProcessingEndpointName());
 }
開發者ID:AlexRhees,項目名稱:ServiceControl,代碼行數:8,代碼來源:TransportMessageExtensionsTests.cs

示例10: MutateOutgoing

    public void MutateOutgoing(object[] messages, TransportMessage transportMessage)
    {
        var incomingContext = bus.CurrentMessageContext;
        var incomingMessageId = incomingContext?.Headers["NServiceBus.MessageId"];

        transportMessage.Headers
            .Add("MutateTransportMessages_Outgoing", "ValueMutateTransportMessages_Outgoing");
    }
開發者ID:chriscatilo,項目名稱:docs.particular.net,代碼行數:8,代碼來源:MutateTransportMessages.cs

示例11: No_headers_with_message_type_should_throw_with_message_id_and_types

 public void No_headers_with_message_type_should_throw_with_message_id_and_types()
 {
     var message = new TransportMessage(Guid.Empty.ToString(), new Dictionary<string, string>
                                                               {
                                                                   { Headers.EnclosedMessageTypes ,"TheMessageType"}
                                                               });
     var exception = Assert.Throws<Exception>(() => { message.ProcessingEndpointName(); });
     Assert.AreEqual("No processing endpoint could be determined for message (00000000-0000-0000-0000-000000000000) with EnclosedMessageTypes (TheMessageType)", exception.Message);
 }
開發者ID:AlexRhees,項目名稱:ServiceControl,代碼行數:9,代碼來源:TransportMessageExtensionsTests.cs

示例12: MutateOutgoing

        public void MutateOutgoing(LogicalMessage message, TransportMessage transportMessage)
        {
            log.Info("transportMessage.Body size before compression: " + transportMessage.Body.Length);

            transportMessage.Body = Compress(transportMessage.Body);
            transportMessage.Headers.Add(Constants.Headers.Keys.Compressed, Constants.Headers.Values.Compressed);

            log.Info("transportMessage.Body size after compression: " + transportMessage.Body.Length);
        }
開發者ID:jmeckley,項目名稱:MessageMutators,代碼行數:9,代碼來源:TransportMessageCompressionMutator.cs

示例13: MutateOutgoing

        public void MutateOutgoing(object[] messages, TransportMessage transportMessage)
        {
            if (Bus.CurrentMessageContext == null)
                return;
            if (!Bus.CurrentMessageContext.Headers.ContainsKey("tenant"))
                return;

            transportMessage.Headers["tenant"] = Bus.CurrentMessageContext.Headers["tenant"];
        }
開發者ID:JoeShook,項目名稱:NServiceBus,代碼行數:9,代碼來源:EndpointConfig.cs

示例14: MutateOutgoing

        public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage)
        {
            var command = logicalMessage.Instance as IOrderCommand;

            if (command != null)
            {
                transportMessage.Headers[Headers.ConversationId] = command.OrderId;
            }
        }
開發者ID:calebjenkins,項目名稱:SagaMasterClass.Skeleton,代碼行數:9,代碼來源:SetConversationId.cs

示例15: HandleMessage

        protected override void HandleMessage(TransportMessage message)
        {
            var destinationAddress = Address.Parse(message.Headers["ServiceControl.TargetEndpointAddress"]);

            message.Headers.Remove("ServiceControl.TargetEndpointAddress");
            message.Headers.Remove("ServiceControl.Retry.StagingId");

            sender.Send(message, destinationAddress);
        }
開發者ID:SaintLoong,項目名稱:ServiceControl,代碼行數:9,代碼來源:ReturnToSenderDequeuer.cs


注:本文中的NServiceBus.TransportMessage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。