当前位置: 首页>>代码示例>>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;未经允许,请勿转载。