2

我刚刚熟悉了 NServiceBus,并且收到了 MessageDeserialization 异常和堆栈跟踪,如下所示。

对于一些环境信息......我正在使用带有队列的天蓝色持久性。我可以看到订阅表以及订阅者的所有端点地址。

我有 3 个 MVC Web API 托管应用程序。发布导致此异常的消息的服务/API 在其 app.config 中配置为订阅自身和其他 2 个 api。其他似乎没有问题的人只有 1 个订阅。第一个订阅它自己的一个事件。另一个订阅来自第 3 个服务/api 的 3 个事件。

我为解决问题而尝试过的事情。我使用约定来定义我的事件,但现在我的事件消息都实现了 IEvent。我还定义了 JsonSerializer。这是我的总线配置设置...

public class NServiceBusEndpointConfig : IConfigureThisEndpoint, AsA_Worker
{
    public static IBus bus;

    public void Customize(BusConfiguration busConfig)
    {
        var configuration = ContainerConfig.Container.Resolve<ICredentialDomainConfig>();

        busConfig.AzureConfigurationSource();
        busConfig.UseTransport<AzureStorageQueueTransport>()
            .ConnectionString(configuration.NServiceBusQueueConnectionString);
        busConfig.UsePersistence<AzureStoragePersistence>();
        busConfig.EndpointName("service1");

        busConfig.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(ContainerConfig.Container));
        busConfig.UseSerialization<JsonSerializer>();  
        busConfig.License(configuration.NServiceBusLicenseString);
    }
}

}

这是异常和堆栈跟踪详细信息...

"NServiceBus.ExceptionInfo.ExceptionType": "NServiceBus.MessageDeserializationException",
      "NServiceBus.ExceptionInfo.InnerExceptionType": "System.Exception",
      "NServiceBus.ExceptionInfo.HelpLink": null,
      "NServiceBus.ExceptionInfo.Message": "An error occurred while attempting to extract logical messages from transport message

8dea1c2f-babb-438d-8e4c-a4cd002f5ab6”、“NServiceBus.ExceptionInfo.Source”:“NServiceBus.Core”、“NServiceBus.ExceptionInfo.StackTrace”:“NServiceBus.MessageDeserializationException:尝试从传输消息中提取逻辑消息时出错8dea1c2f-babb-438d-8e4c-a4cd002f5ab6 ---> System.Exception: 找不到“Newtonsoft.Json.Linq.JObject”的元数据。\r\n请确保以下内容:\r\n1. 'Newtonsoft.Json.Linq.JObject' 包含在初始扫描中。\r\n2. “Newtonsoft.Json.Linq.JObject”实现“IMessage”、“IEvent”或“ICommand”,或者,如果您不想实现接口,则可以使用“不显眼模式”。\r\n 在 NServiceBus .Unicast.Messages。2 headers) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Unicast\\Messages\\LogicalMessageFactory.cs:line 59\r\n at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext()\r\n 在 System.Collections.Generic.List 1..ctor(IEnumerable1 集合)\r\n 在 System.Linq.Enumerable.ToList[TSource](IEnumerable 1.InvokeNext(T context) 在 c:\BuildAgent\ work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 107\r\n at NServiceBus.BehaviorChain 1.InvokeNext(T context) in c:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline \BehaviorChain.cs:line 107\r\n 在 NServiceBus.BehaviorChain 1.InvokeNext(T context) 在 c:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 107\r\n在 NServiceBus.BehaviorChain 1.InvokeNext(T context) 在 c:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 107\r\n 在 NServiceBus.BehaviorChain1 source)\r\n
at NServiceBus.DeserializeLogicalMessagesBehavior.Extract(TransportMessage physicalMessage) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Unicast\\Messages\\DeserializeLogicalMessagesBehavior.cs:line 93\r\n at NServiceBus.DeserializeLogicalMessagesBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Unicast\\Messages\\DeserializeLogicalMessagesBehavior.cs:line 40\r\n --- End of inner exception stack trace ---\r\n at NServiceBus.DeserializeLogicalMessagesBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Unicast\\Messages\\DeserializeLogicalMessagesBehavior.cs:line 47\r\n at NServiceBus.BehaviorChain
1.<>c__DisplayClass5.<InvokeNext>b__2() in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Pipeline\\BehaviorChain.cs:line 95\r\n at NServiceBus.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\MessageMutator\\ApplyIncomingTransportMessageMutatorsBehavior.cs:line 20\r\n at NServiceBus.BehaviorChain1.<>c__DisplayClass5.<InvokeNext>b__2() in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Pipeline\\BehaviorChain.cs:line 95\r\n at NServiceBus.SubscriptionReceiverBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Unicast\\Subscriptions\\MessageDrivenSubscriptions\\SubscriptionReceiverBehavior.cs:line 32\r\n at NServiceBus.BehaviorChain1.<>c__DisplayClass5.<InvokeNext>b__2() in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Pipeline\\BehaviorChain.cs:line 95\r\n at NServiceBus.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\UnitOfWork\\UnitOfWorkBehavior.cs:line 42\r\n at NServiceBus.BehaviorChain1.<>c__DisplayClass5.<InvokeNext>b__2() in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Pipeline\\BehaviorChain.cs:line 95\r\n at NServiceBus.ChildContainerBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Unicast\\Behaviors\\ChildContainerBehavior.cs:line 17\r\n at NServiceBus.BehaviorChain1.InvokeNext(T context) in c:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 107\r\n at NServiceBus.BehaviorChain 1.<>c__DisplayClass5.<InvokeNext>b__2() in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Pipeline\\BehaviorChain.cs:line 95\r\n at NServiceBus.ProcessingStatisticsBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Monitoring\\ProcessingStatisticsBehavior.cs:line 23\r\n at NServiceBus.BehaviorChain1.InvokeNext(T context) in c:\ BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\BehaviorChain.cs:line 107\r\n 在 NServiceBus.BehaviorChain 1.<>c__DisplayClass5.<InvokeNext>b__2() in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Pipeline\\BehaviorChain.cs:line 95\r\n at NServiceBus.AuditBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Audit\\AuditBehavior.cs:line 20\r\n at NServiceBus.BehaviorChain1.InvokeNext(T context) 在 c:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core \Pipeline\BehaviorChain.cs:第 107 行\r\n 在 NServiceBus.BehaviorChain1.Invoke() in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Pipeline\\BehaviorChain.cs:line 58\r\n at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain1 pipelineAction, T context) in c:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\PipelineExecutor.cs:line 129\r\n at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage message) in c :\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Unicast\Transport\TransportReceiver.cs:line 328",

      "NServiceBus.FailedQ": "<<Queue,
      "NServiceBus.TimeOfFailure": "2015-07-06 02:52:26:254996 Z"

这是所要求的消息类......最初消息中有3个不同的“信息”,但试图简化,所以现在只有事件中的权限信息......

  public class CredentialPermissionGrantedEvent : IEvent
    {
        public PermissionInfo Permission { get; set; }
    }    

public class PermissionInfo
    {
        public Guid PermissionReference { get; set; }
        public DateTime ActivationDate { get; set; }
        public Guid CredentialReference { get; set; }
        public Guid DeviceReference { get; set; }
        public DateTime ExpirationDate { get; set; }
        public string Function { get; set; }
        public Guid ScheduleReference { get; set; }
        public long Timestamp { get; set; }
    }

任何帮助将不胜感激

  • 保罗
4

2 回答 2

0

看起来 json.net 正在将您的消息反序列化为 JObject 而不是消息的类型,两个端点是否都知道相同的类型?如果查看消息正文,是否包含必要的 json.net 元数据($type)?

于 2015-07-09T19:46:20.883 回答
0
  • ServiceControl 在发送消息以进行重新处理时将其回调地址标头(它发生在 SQLServer 和 RabbitMQ 传输中)添加到消息中
  • 处理程序在处理消息时调用 Bus.Reply 或 Bus.Return
  • 回复被路由到 SC 回调队列而不是实际目的地(在回复字段中设置)

在此处查找更多指南

于 2017-03-07T10:49:01.260 回答