在NServiceBus

时间:2015-07-06 03:18:48

标签: azure nservicebus nservicebus5

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

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

我有3个MVC Web API托管应用。发布导致此异常的消息的Service / API在其app.config中配置为订阅自身和其他2个api。其他似乎没有问题的人只有1个订阅。第一个订阅了自己的一个事件。另一个订阅了来自3rd service / 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 ---&gt; System.Exception:不能   找到'Newtonsoft.Json.Linq.JObject'的元数据。\ r \ n请确保   以下内容:\ r \ N1。 'Newtonsoft.Json.Linq.JObject'包含在首字母中   扫描。 \ r \ N2。 'Newtonsoft.Json.Linq.JObject'实现了   'IMessage','IEvent'或'ICommand'或者,如果你不想要的话   要实现一个界面,你可以使用'Unobtrusive Mode'。\ r \ n at   NServiceBus.Unicast.Messages.LogicalMessageFactory.Create(类型   messageType,Object message,Dictionary 2 headers) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Unicast\\Messages\\LogicalMessageFactory.cs:line 59\r\n at System.Linq.Enumerable.WhereSelectArrayIterator 2.MoveNext()\ r \ n at   System.Collections.Generic.List 1..ctor(IEnumerable 1个集合)\ r \ n   在System.Linq.Enumerable.ToList [TSource](IEnumerable 1 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.InvokeNext(T context)in   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \管道\ BehaviorChain.cs:行   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.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\MessageMutator\\ApplyIncomingTransportMessageMutatorsBehavior.cs:line 20\r\n at NServiceBus.BehaviorChain 1.InvokeNext(T context)in   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \管道\ BehaviorChain.cs:行   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.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.BehaviorChain 1.InvokeNext(T context)in   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \管道\ BehaviorChain.cs:行   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.UnitOfWorkBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\UnitOfWork\\UnitOfWorkBehavior.cs:line 42\r\n at NServiceBus.BehaviorChain 1.InvokeNext(T context)in   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \管道\ BehaviorChain.cs:行   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.ChildContainerBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Unicast\\Behaviors\\ChildContainerBehavior.cs:line 17\r\n at NServiceBus.BehaviorChain 1.InvokeNext(T context)in   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \管道\ BehaviorChain.cs:行   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.BehaviorChain 1.InvokeNext(T context)in   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \管道\ BehaviorChain.cs:行   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.AuditBehavior.Invoke(IncomingContext context, Action next) in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Audit\\AuditBehavior.cs:line 20\r\n at NServiceBus.BehaviorChain 1.InvokeNext(T context)in   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \管道\ BehaviorChain.cs:行   107 \ r \ n在NServiceBus.BehaviorChain 1.Invoke() in c:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Pipeline\\BehaviorChain.cs:line 58\r\n at NServiceBus.Pipeline.PipelineExecutor.Execute[T](BehaviorChain 1   pipelineAction,T context)in   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \管道\ PipelineExecutor.cs:行   129 \ r \ n at   NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMessage   消息)   C:\ BuildAgent \工作\ 3206e2123f54fce4的\ src \ NServiceBus.Core \单播\传输\ TransportReceiver.cs:行   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; }
    }

非常感谢任何帮助

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

  • ServiceControl添加其回调地址标头(它发生在 发送它时,SQLServer和RabbitMQ传输到消息 再加工
  • 处理消息的处理程序调用Bus.Reply或 Bus.Return
  • 回复被路由到SC回调队列而不是实际 目的地(在回复字段中设置)

查找更多指南here