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


C# BrokeredMessage.SafelyGetBodyTypeNameOrDefault方法代码示例

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


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

示例1: Create

 public static MessageMetadata Create(BrokeredMessage message)
 {
     var typeFullName = message.SafelyGetBodyTypeNameOrDefault();
     var shortMessageTypeName = typeFullName == null
                        ? null
                        : typeFullName.Split('.').Last();
     return new MessageMetadata(Guid.Parse(message.MessageId), Guid.Parse(message.CorrelationId), shortMessageTypeName, typeFullName);
 }
开发者ID:Royal-Jay,项目名称:Zombus,代码行数:8,代码来源:MessageDispatchLoggingExtensions.cs

示例2: GetBodyType

 private Type GetBodyType(BrokeredMessage message)
 {
     var typeName = message.SafelyGetBodyTypeNameOrDefault();
     var candidates = _messageTypes.Where(t => t.FullName == typeName).ToArray();
     if (candidates.Any() == false)
         throw new Exception($"The type '{typeName}' was not discovered by the type provider and cannot be loaded.");
     
     return candidates.Single();
 }
开发者ID:AtmosphereMessaging,项目名称:Cumulus-vNext,代码行数:9,代码来源:AzureServicebusTransport.cs

示例3: Dispatch

        private async Task Dispatch(BrokeredMessage message)
        {
            // Early exit: have we pre-fetched this message and had our lock already expire? If so, just
            // bail - it will already have been picked up by someone else.
            if (message.LockedUntilUtc <= _clock.UtcNow)
            {
                GlobalMessageCounters.IncrementMessagesDroppedDueToExpiredLock(1);

                _logger.Debug("Lock for message {MessageId} appears to have already expired so we're not dispatching it. Watch out for clock drift between your service bus server and {MachineName}!", message.MessageId, Environment.MachineName);
                return;
            }

            try
            {
                Exception exception = null;

                try
                {
                    LogInfo("Dispatching", message);
                    using (_dispatchContextManager.StartNewDispatchContext(new SubsequentDispatchContext(message)))
                    {
                        await _taskFactory.StartNew(() => _messageDispatcher.Dispatch(message), TaskContext.Dispatch).Unwrap();
                    }
                    LogDebug("Dispatched", message);

                    LogDebug("Completing", message);
                    message.Properties[MessagePropertyKeys.DispatchComplete] = true;
                    await _taskFactory.StartNew(() => message.CompleteAsync(), TaskContext.CompleteOrAbandon).Unwrap();
                    LogInfo("Completed", message);

                    return;
                }

                catch (Exception exc)
                {
                    if (exc is MessageLockLostException || (exc.InnerException is MessageLockLostException))
                    {
                        _logger.Error(exc,
                                      "Message completion failed for {Type} from {QueuePath} [MessageId:{MessageId}, CorrelationId:{CorrelationId}]",
                                      message.SafelyGetBodyTypeNameOrDefault(),
                                      message.ReplyTo,
                                      message.MessageId,
                                      message.CorrelationId);
                        return;
                    }

                    _logger.Error(exc,
                                  "Message dispatch failed for {Type} from {QueuePath} [MessageId:{MessageId}, CorrelationId:{CorrelationId}]",
                                  message.SafelyGetBodyTypeNameOrDefault(),
                                  message.ReplyTo,
                                  message.MessageId,
                                  message.CorrelationId);

                    exception = exc;
                }

                try
                {
                    LogDebug("Abandoning", message);
                    message.Properties[MessagePropertyKeys.DispatchAbandoned] = true;
                    await message.AbandonAsync(exception.ExceptionDetailsAsProperties(_clock.UtcNow));
                    LogDebug("Abandoned", message);
                }
                catch (Exception exc)
                {
                    _logger.Error(exc,
                                  "Could not call Abandon() on message {Type} from {QueuePath} [MessageId:{MessageId}, CorrelationId:{CorrelationId}].",
                                  message.SafelyGetBodyTypeNameOrDefault(),
                                  message.MessageId,
                                  message.CorrelationId,
                                  message.ReplyTo);
                }
            }
            catch (Exception exc)
            {
                _logger.Fatal(exc, "Unhandled exception in message pump");
            }
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:78,代码来源:MessagePump.cs

示例4: LogInfo

 private void LogInfo(string activity, BrokeredMessage message)
 {
     _logger.Info("{MessagePumpAction} message {Type} from {QueuePath} [MessageId:{MessageId}, CorrelationId:{CorrelationId}]",
                  activity,
                  message.SafelyGetBodyTypeNameOrDefault(),
                  message.ReplyTo,
                  message.MessageId,
                  message.CorrelationId);
 }
开发者ID:AtmosphereMessaging,项目名称:Cumulus,代码行数:9,代码来源:MessagePump.cs

示例5: Dispatch

        private async Task Dispatch(BrokeredMessage message)
        {
            try
            {
                Exception exception = null;

                try
                {
                    LogInfo("Dispatching", message);
                    using (_dispatchContextManager.StartNewDispatchContext(new DispatchContext(message)))
                    {
                        await _messageDispatcher.Dispatch(message);
                    }
                    LogDebug("Dispatched", message);

                    LogDebug("Completing", message);
                    await message.CompleteAsync();
                    LogInfo("Completed", message);

                    return;
                }
                catch (Exception exc)
                {
                    exception = exc;
                }

                _logger.Error(exception,
                              "Message dispatch failed for {0} from {1} [MessageId:{2}, CorrelationId:{3}]",
                              message.SafelyGetBodyTypeNameOrDefault(),
                              message.ReplyTo,
                              message.MessageId,
                              message.CorrelationId);

                try
                {
                    LogDebug("Abandoning", message);
                    await message.AbandonAsync(exception.ExceptionDetailsAsProperties(_clock.UtcNow));
                    LogDebug("Abandoned", message);
                }
                catch (Exception exc)
                {
                    _logger.Error(exc,
                                  "Could not call Abandon() on message {0} from {1} [MessageId:{2}, CorrelationId:{3}]. Possible lock expiry?",
                                  message.SafelyGetBodyTypeNameOrDefault(),
                                  message.MessageId,
                                  message.CorrelationId,
                                  message.ReplyTo);
                }
            }
            catch (Exception exc)
            {
                _logger.Error(exc, "Unhandled exception in message pump");
            }
        }
开发者ID:Joshscorp,项目名称:Nimbus,代码行数:54,代码来源:MessagePump.cs

示例6: GetBodyType

        public Type GetBodyType(BrokeredMessage message)
        {
            var typeName = message.SafelyGetBodyTypeNameOrDefault();
            var candidates = _typeProvider.AllMessageContractTypes().Where(t => t.FullName == typeName).ToArray();
            if (candidates.Any() == false)
                throw new Exception("The type '{0}' was not discovered by the type provider and cannot be loaded.".FormatWith(typeName));

            // The TypeProvider should not provide a list of duplicates
            return candidates.Single();
        }
开发者ID:Royal-Jay,项目名称:Zombus,代码行数:10,代码来源:BrokeredMessageFactory.cs


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