当前位置: 首页>>代码示例>>C#>>正文


C# Transport.TransportMessage类代码示例

本文整理汇总了C#中NServiceBus.Unicast.Transport.TransportMessage的典型用法代码示例。如果您正苦于以下问题:C# TransportMessage类的具体用法?C# TransportMessage怎么用?C# TransportMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransportMessage类属于NServiceBus.Unicast.Transport命名空间,在下文中一共展示了TransportMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetUp

 public void SetUp()
 {
     destination = Target.Input;
     XmsUtilities.Purge(destination);
     received = null;
     sent = new TransportMessage().WithBody();;
 }
开发者ID:sasha-uk,项目名称:NServiceBus.Xms.2,代码行数:7,代码来源:XmsUtilitiesTest.cs

示例2: Send

        public void Send(TransportMessage message, Address address)
        {
            try
            {
                XmsAddress addr = address.ToXmsAddress();
                using (var producer = provider.GetProducer(addr))
                {
                    var xmsMessage = producer.CreateBytesMessage();
                    XmsUtilities.Convert(message, xmsMessage);
                    producer.Send(xmsMessage);
                    message.Id = xmsMessage.JMSMessageID;
                   
                }
            }
            // TODO: QueueNotFoundException
            catch (Exception ex)
            {
                if (address == null)
                    throw new FailedToSendMessageException("Failed to send message.", ex);

                throw new FailedToSendMessageException(
                    string.Format("Failed to send message to address: {0}@{1}", address.Queue, address.Machine), ex);
            }
         
        }
开发者ID:sasha-uk,项目名称:NServiceBus.Xms.3,代码行数:25,代码来源:XmsMessageSender.cs

示例3: Defer

        public void Defer(TransportMessage message, DateTime processAt, Address address)
        {
            message.Headers[ScheduledMessage.AMQ_SCHEDULED_DELAY] =
                ((int)processAt.Subtract(DateTime.UtcNow).TotalMilliseconds).ToString(CultureInfo.InvariantCulture);

            this.MessageSender.Send(message, address);
        }
开发者ID:afyles,项目名称:NServiceBus,代码行数:7,代码来源:ActiveMQMessageDefer.cs

示例4: 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

示例5: using

        void ISendMessages.Send(TransportMessage message, Address address)
        {
            var queuePath = MsmqUtilities.GetFullPath(address);

            using (var q = new MessageQueue(queuePath, QueueAccessMode.Send))
            {
                var toSend = MsmqUtilities.Convert(message);

                toSend.UseDeadLetterQueue = UseDeadLetterQueue;
                toSend.UseJournalQueue = UseJournalQueue;

                if (message.ReplyToAddress != null)
                    toSend.ResponseQueue = new MessageQueue(MsmqUtilities.GetReturnAddress(message.ReplyToAddress.ToString(), address.ToString()));

                try
                {
                    q.Send(toSend, GetTransactionTypeForSend());
                }
                catch (MessageQueueException ex)
                {
                    if (ex.MessageQueueErrorCode == MessageQueueErrorCode.QueueNotFound)
                        throw new QueueNotFoundException { Queue = address };

                    throw;
                }

                message.Id = toSend.Id;
            }
        }
开发者ID:rhinof,项目名称:NServiceBus,代码行数:29,代码来源:MsmqMessageSender.cs

示例6:

        void IManageMessageFailures.ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e)
        {
            if (SanitizeProcessingExceptions)
                e = ExceptionSanitizer.Sanitize(e);

            this.SendFailureMessage(message, e, "ProcessingFailed");
        }
开发者ID:martinernst,项目名称:NServiceBus,代码行数:7,代码来源:FaultManager.cs

示例7: CloneAndSendLocal

        void CloneAndSendLocal(TransportMessage messageToDispatch, Site destinationSite)
        {
            //todo - do we need to clone? check with Jonathan O
            messageToDispatch.Headers[Headers.DestinationSites] = destinationSite.Key;

            messageSender.Send(messageToDispatch, localAddress);
        }
开发者ID:nghead,项目名称:NServiceBus,代码行数:7,代码来源:GatewaySender.cs

示例8: IncrementFailuresForMessage

        public void IncrementFailuresForMessage(TransportMessage message, Exception e)
        {
            var item = failuresPerMessage.AddOrUpdate(message.Id, s => new Tuple<int, Exception>(1, e),
                (s, i) => new Tuple<int, Exception>(i.Item1 + 1, e));

            notifications.Errors.InvokeMessageHasFailedAFirstLevelRetryAttempt(item.Item1, message, e);
        }
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:7,代码来源:FirstLevelRetries.cs

示例9: TryInvokeFaultManager

        private bool TryInvokeFaultManager(TransportMessage message, Exception exception)
        {
            try
            {
                Exception e = exception;

                if (e is AggregateException)
                {
                    e = e.GetBaseException();
                }

                if (e is TransportMessageHandlingFailedException)
                {
                    e = e.InnerException;
                }

                message.RevertToOriginalBodyIfNeeded();

                failureManager.ProcessingAlwaysFailsForMessage(message, e);

                return true;
            }
            catch (Exception ex)
            {
                Configure.Instance.RaiseCriticalError(
                    String.Format("Fault manager failed to process the failed message with id {0}", message.Id), ex);
            }

            return false;
        }
开发者ID:robert-hickey,项目名称:NServiceBus,代码行数:30,代码来源:FirstLevelRetries.cs

示例10:

        void IMutateOutgoingTransportMessages.MutateOutgoing(IMessage[] messages, TransportMessage transportMessage)
        {
            if (transportMessage.Headers.ContainsKey(WindowsIdentityName))
                transportMessage.Headers.Remove(WindowsIdentityName);

            transportMessage.Headers.Add(WindowsIdentityName, Thread.CurrentPrincipal.Identity.Name);
        }
开发者ID:MaggiePlusPlus,项目名称:NServiceBus,代码行数:7,代码来源:ImpersonationManager.cs

示例11: ToEventData

        private static EventData ToEventData(TransportMessage transportMessage, EventStoreMessageMetadata metadata)
        {
            metadata.CorrelationId = transportMessage.CorrelationId;
            metadata.MessageId = transportMessage.Id;
            metadata.ReplyTo = transportMessage.ReplyToAddress.ToString();
            metadata.Headers = transportMessage.Headers;
            var type = transportMessage.IsControlMessage() 
                              ? "ControlMessage" 
                              : transportMessage.Headers[Headers.EnclosedMessageTypes];

            byte[] data;
            string contentType;
            if (transportMessage.Headers.TryGetValue(Headers.ContentType, out contentType))
            {
                if (contentType != ContentTypes.Json)
                {
                    throw new InvalidOperationException("Invalid content type: "+contentType);
                }
                data = transportMessage.Body;
            }
            else
            {
                data = new byte[0];
            }
            return new EventData(Guid.NewGuid(), type, true, data, metadata.ToJsonBytes());
        }
开发者ID:eric-swann-q2,项目名称:NServiceBus.EventStore,代码行数:26,代码来源:TransportMessageConverter.cs

示例12: 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

示例13: Send

        public void Send(TransportMessage message, string destination)
        {
            var address = MsmqUtilities.GetFullPath(destination);

            using (var q = new MessageQueue(address, QueueAccessMode.Send))
            {
                var toSend = new Message();

                if (message.Body != null)
                    toSend.BodyStream = new MemoryStream(message.Body);

                if (message.CorrelationId != null)
                    toSend.CorrelationId = message.CorrelationId;

                toSend.Recoverable = message.Recoverable;
                toSend.UseDeadLetterQueue = UseDeadLetterQueue;
                toSend.UseJournalQueue = UseJournalQueue;

                if (!string.IsNullOrEmpty(message.ReturnAddress))
                    toSend.ResponseQueue = new MessageQueue(MsmqUtilities.GetReturnAddress(message.ReturnAddress, destination));

                if (message.TimeToBeReceived < MessageQueue.InfiniteTimeout)
                    toSend.TimeToBeReceived = message.TimeToBeReceived;

                if (message.Headers == null)
                    message.Headers = new Dictionary<string, string>();

                if (!message.Headers.ContainsKey(HeaderKeys.IDFORCORRELATION))
                    message.Headers.Add(HeaderKeys.IDFORCORRELATION, null);

                if (String.IsNullOrEmpty(message.Headers[HeaderKeys.IDFORCORRELATION]))
                    message.Headers[HeaderKeys.IDFORCORRELATION] = message.IdForCorrelation;

                using (var stream = new MemoryStream())
                {
                    headerSerializer.Serialize(stream, message.Headers.Select(pair => new HeaderInfo { Key = pair.Key, Value = pair.Value }).ToList());
                    toSend.Extension = stream.GetBuffer();
                }

                toSend.AppSpecific = (int)message.MessageIntent;

                try
                {
                    if (MsmqUtilities.CurrentTransaction != null)
                        q.Send(toSend, MsmqUtilities.CurrentTransaction);
                    else
                        q.Send(toSend, GetTransactionTypeForSend());
                }
                catch (MessageQueueException ex)
                {
                    if (ex.MessageQueueErrorCode == MessageQueueErrorCode.QueueNotFound)
                        throw new QueueNotFoundException { Queue = destination };

                    throw;
                }

                message.Id = toSend.Id;
            }
        }
开发者ID:martinernst,项目名称:NServiceBus,代码行数:59,代码来源:MsmqMessageSender.cs

示例14: SerializationFailedForMessage

 public void SerializationFailedForMessage(TransportMessage message, Exception e)
 {
     if (_logger.IsDebugEnabled)
      {
     _logger.Debug(string.Format("Serialization failed for message {0} -- persisting to failure store.", message.Id));
      }
      Save(new FailureInfo(message, e, true));
 }
开发者ID:togakangaroo,项目名称:NServiceBus,代码行数:8,代码来源:FaultManager.cs

示例15: ProcessingAlwaysFailsForMessage

 public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e)
 {
     if (_logger.IsDebugEnabled)
      {
     _logger.Debug(string.Format("All processing attempts failed for message {0} -- pesisting to failure store.", message.Id));
      }
      Save(new FailureInfo(message, e, false));
 }
开发者ID:togakangaroo,项目名称:NServiceBus,代码行数:8,代码来源:FaultManager.cs


注:本文中的NServiceBus.Unicast.Transport.TransportMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。