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


C# TransportMessage.GetMessageLabel方法代码示例

本文整理汇总了C#中Rebus.Messages.TransportMessage.GetMessageLabel方法的典型用法代码示例。如果您正苦于以下问题:C# TransportMessage.GetMessageLabel方法的具体用法?C# TransportMessage.GetMessageLabel怎么用?C# TransportMessage.GetMessageLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rebus.Messages.TransportMessage的用法示例。


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

示例1: Deserialize

        public async Task<Message> Deserialize(TransportMessage transportMessage)
        {
            string contentEncoding;

            if (!transportMessage.Headers.TryGetValue(Headers.ContentEncoding, out contentEncoding))
            {
                return await _serializer.Deserialize(transportMessage);
            }

            if (contentEncoding != GzipEncodingHeader)
            {
                var message = $"The message {transportMessage.GetMessageLabel()} has a '{Headers.ContentEncoding}' with the" +
                              $" value '{contentEncoding}', but this serializer decorator only knows how to decompress" +
                              $" '{GzipEncodingHeader}'";

                throw new ArgumentException(message);
            }

            var headers = transportMessage.Headers.Clone();
            var compressedBody = transportMessage.Body;

            headers.Remove(Headers.ContentEncoding);

            var uncompressedBody = _zipper.Unzip(compressedBody);
            var uncompressedTransportMessage = new TransportMessage(headers, uncompressedBody);

            return await _serializer.Deserialize(uncompressedTransportMessage);
        }
开发者ID:RichieYang,项目名称:Rebus,代码行数:28,代码来源:ZippingSerializerDecorator.cs

示例2: HandleMessage

        public void HandleMessage(TransportMessage transportMessage, ITransactionContext transactionContext)
        {
            var message = transportMessage.GetMessageLabel();

            var options = new List<KeyOption>();

            if (DefaultOutputQueue != null)
            {
                options.Add(KeyOption.New('d',
                    () => { MoveMessage(transportMessage, transactionContext, DefaultOutputQueue); },
                    "Move to default queue '{0}'", DefaultOutputQueue));
            }

            if (transportMessage.Headers.ContainsKey(Headers.SourceQueue))
            {
                var sourceQueue = transportMessage.Headers[Headers.SourceQueue];

                options.Add(KeyOption.New('s',
                    () => { MoveMessage(transportMessage, transactionContext, sourceQueue); },
                    "Return to source queue '{0}'", sourceQueue));
            }

            options.Add(KeyOption.New('c', () =>
            {
                Console.Write("queue > ");
                var queueName = Console.ReadLine();
                MoveMessage(transportMessage, transactionContext, queueName);
            }, "Enter custom queue name to move message to"));

            Prompt(message, options);

            Text.PrintLine();
        }
开发者ID:xenoputtss,项目名称:Rebus,代码行数:33,代码来源:ReturnToSourceQueue.cs

示例3: CreateBrokeredMessage

        public static BrokeredMessage CreateBrokeredMessage(TransportMessage message)
        {
            var headers = message.Headers.Clone();
            var brokeredMessage = new BrokeredMessage(new MemoryStream(message.Body), true);

            string timeToBeReceivedStr;
            if (headers.TryGetValue(Headers.TimeToBeReceived, out timeToBeReceivedStr))
            {
                timeToBeReceivedStr = headers[Headers.TimeToBeReceived];
                var timeToBeReceived = TimeSpan.Parse(timeToBeReceivedStr);
                brokeredMessage.TimeToLive = timeToBeReceived;
            }

            string deferUntilTime;
            if (headers.TryGetValue(Headers.DeferredUntil, out deferUntilTime))
            {
                var deferUntilDateTimeOffset = deferUntilTime.ToDateTimeOffset();
                brokeredMessage.ScheduledEnqueueTimeUtc = deferUntilDateTimeOffset.UtcDateTime;
                headers.Remove(Headers.DeferredUntil);
            }

            string contentType;
            if (headers.TryGetValue(Headers.ContentType, out contentType))
            {
                brokeredMessage.ContentType = contentType;
            }

            string correlationId;
            if (headers.TryGetValue(Headers.CorrelationId, out correlationId))
            {
                brokeredMessage.CorrelationId = correlationId;
            }

            brokeredMessage.Label = message.GetMessageLabel();

            foreach (var kvp in headers)
            {
                brokeredMessage.Properties[kvp.Key] = PossiblyLimitLength(kvp.Value);
            }

            return brokeredMessage;
        }
开发者ID:RichieYang,项目名称:Rebus,代码行数:42,代码来源:MsgHelpers.cs

示例4: ForwardMessageToExternalTimeoutManager

        async Task ForwardMessageToExternalTimeoutManager(TransportMessage transportMessage, ITransactionContext transactionContext)
        {
            var timeoutManagerAddress = _options.ExternalTimeoutManagerAddressOrNull;

            _log.Info("Forwarding deferred message {0} to external timeout manager '{1}'",
                transportMessage.GetMessageLabel(), timeoutManagerAddress);

            await _transport.Send(timeoutManagerAddress, transportMessage, transactionContext);
        }
开发者ID:geffzhang,项目名称:Rebus,代码行数:9,代码来源:HandleDeferredMessagesStep.cs

示例5: GetMessageLabel

 static string GetMessageLabel(TransportMessage message)
 {
     try
     {
         return message.GetMessageLabel();
     }
     catch
     {
         // if that failed, it's most likely because we're running in legacy mode - therefore:
         return message.Headers.GetValueOrNull(Headers.MessageId)
                ?? message.Headers.GetValueOrNull("rebus-msg-id")
                ?? "<unknown ID>";
     }
 }
开发者ID:nls75,项目名称:Rebus,代码行数:14,代码来源:MsmqTransport.cs

示例6: ProcessMessage

        async Task ProcessMessage(TransactionContext context, TransportMessage transportMessage)
        {
            try
            {
                context.Items["OwningBus"] = _owningBus;

                AmbientTransactionContext.SetCurrent(context);

                var incomingSteps = _pipeline.ReceivePipeline();
                var stepContext = new IncomingStepContext(transportMessage, context);
                await _pipelineInvoker.Invoke(stepContext, incomingSteps);

                try
                {
                    await context.Complete();
                }
                catch (Exception exception)
                {
                    _log.Error(exception, "An error occurred when attempting to complete the transaction context");
                }
            }
            catch (ThreadAbortException exception)
            {
                context.Abort();

                _log.Error(exception, $"Worker was killed while handling message {transportMessage.GetMessageLabel()}");
            }
            catch (Exception exception)
            {
                context.Abort();

                _log.Error(exception, $"Unhandled exception while handling message {transportMessage.GetMessageLabel()}");
            }
            finally
            {
                AmbientTransactionContext.SetCurrent(null);
            }
        }
开发者ID:rebus-org,项目名称:Rebus,代码行数:38,代码来源:ThreadPoolWorker.cs

示例7: CreateBrokeredMessage

        static BrokeredMessage CreateBrokeredMessage(TransportMessage message)
        {
            var headers = message.Headers;
            var brokeredMessage = new BrokeredMessage(new MemoryStream(message.Body), true);

            foreach (var kvp in headers)
            {
                brokeredMessage.Properties[kvp.Key] = PossiblyLimitLength(kvp.Value);
            }

            if (headers.ContainsKey(Headers.TimeToBeReceived))
            {
                var timeToBeReceivedStr = headers[Headers.TimeToBeReceived];
                var timeToBeReceived = TimeSpan.Parse(timeToBeReceivedStr);
                brokeredMessage.TimeToLive = timeToBeReceived;
            }

            string contentType;
            if (headers.TryGetValue(Headers.ContentType, out contentType))
            {
                brokeredMessage.ContentType = contentType;
            }

            string correlationId;
            if (headers.TryGetValue(Headers.CorrelationId, out correlationId))
            {
                brokeredMessage.CorrelationId = correlationId;
            }

            brokeredMessage.Label = message.GetMessageLabel();

            return brokeredMessage;
        }
开发者ID:nls75,项目名称:Rebus,代码行数:33,代码来源:BasicAzureServiceBusTransport.cs


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