从 MT 2.9.5 迁移到 4.0.1 并获取"The routingSlip must contain at least one activity log"



我们已经开始了从MassTransit 2.9.5(带有快递员(到MassTransit 4.0.1的旅程。事情进展缓慢,但是好的,我对新的(对我们(的功能感到兴奋...但是我已经用快递了。

这是一项既执行又具有补偿行为的脑力简单活动:

public class AdditionActivity : Activity<AdditionActivity.Args, AdditionActivity.CompLog>
{
    private readonly ILogger _logger;
    public AdditionActivity(ILogger logger)
    {
        _logger = logger;
    }
    public class Args : CorrelatedBy<Guid>
    {
        public Guid CorrelationId { get; set; }
        public int First { get; set; }
        public int Second { get; set; }
    }
    public class CompLog : CorrelatedBy<Guid>
    {
        public Guid CorrelationId { get; set; }
        public int Result { get; set; }
    }
    public async Task<ExecutionResult> Execute(ExecuteContext<Args> context)
    {
        var compLog = new CompLog
        {
            CorrelationId = context.Arguments.CorrelationId,
            Result = context.Arguments.First + context.Arguments.Second
        };
        _logger.Info($"{nameof(AdditionActivity)}[{context.Arguments.CorrelationId} - Adding [{context.Arguments.First}] and [{context.Arguments.Second}] = [{compLog.Result}]");
        await Task.CompletedTask;
        return context.Completed(compLog);
    }
    public async Task<CompensationResult> Compensate(CompensateContext<CompLog> context)
    {
        _logger.Warn($"{nameof(AdditionActivity)}[{context.Log.CorrelationId}] - Ruh roh...  must compensate for add that resulted in [{context.Log.Result}]");
        await Task.CompletedTask;
        return context.Compensated();
    }
}

当我执行包括此活动在内的路由滑道时,它会执行(我看到日志,可以逐步浏览代码(。但是在return context.Completed(compLog)之后,我们在控制台中获得了例外(在错误队列中也将捕获消息在这里(:

Exchange    Procedure.Service.Activities.AdditionActivity.Execute_error
Routing Key 
Redelivered ●
Properties  
message_id: 4ded0000-47b0-38d5-3ae8-08d5701751d5
correlation_id: 924899da-7a61-4b80-819f-f66f166c72e4
delivery_mode:  2
headers:    
Content-Type:   application/vnd.masstransit+json
publishId:  1
MT-Reason:  fault
MT-Fault-ExceptionType: System.ArgumentException
MT-Fault-Message:   The routingSlip must contain at least one activity log
MT-Fault-Timestamp: 2018-02-09T23:46:20.3953028Z
MT-Fault-StackTrace:    at MassTransit.Courier.Hosts.HostCompensateContext`1..ctor(HostInfo host, ConsumeContext`1 context) 
at MassTransit.Courier.Hosts.CompensateActivityHost`2.<Send>d__4.MoveNext() 
at MassTransit.Courier.Hosts.CompensateActivityHost`2.<Send>d__4.MoveNext() 
at GreenPipes.Filters.TeeFilter`1.<Send>d__5.MoveNext() 
at GreenPipes.Filters.OutputPipeFilter`2.<GreenPipes-IFilter<TInput>-Send>d__6.MoveNext() 
at GreenPipes.Filters.OutputPipeFilter`2.<GreenPipes-IFilter<TInput>-Send>d__6.MoveNext() 
at MassTransit.Pipeline.Filters.DeserializeFilter.<Send>d__4.MoveNext() 
at GreenPipes.Filters.RescueFilter`2.<GreenPipes-IFilter<TContext>-Send>d__5.MoveNext()
MT-Host-MachineName:    TYLER-XPS13
MT-Host-ProcessName:    Procedure.Service.vshost
MT-Host-ProcessId:  13040
MT-Host-Assembly:   Procedure.Service
MT-Host-AssemblyVersion:    1.0.0.0
MT-Host-MassTransitVersion: 4.0.1.1390
MT-Host-FrameworkVersion:   4.0.30319.42000
MT-Host-OperatingSystemVersion: Microsoft Windows NT 6.2.9200.0
content_type:   application/vnd.masstransit+json
Payload
1844 bytes
Encoding: string
{
  "messageId": "4ded0000-47b0-38d5-3ae8-08d5701751d5",
  "correlationId": "924899da-7a61-4b80-819f-f66f166c72e4",
  "conversationId": "4ded0000-47b0-38d5-a350-08d570175173",
  "initiatorId": "924899da-7a61-4b80-819f-f66f166c72e4",
  "sourceAddress": "rabbitmq://localhost/Procedure.Service",
  "destinationAddress": "rabbitmq://localhost/Procedure.Service.Activities.AdditionActivity.Execute",
  "messageType": [
    "urn:message:MassTransit.Courier.Contracts:RoutingSlip"
  ],
  "message": {
    "trackingNumber": "924899da-7a61-4b80-819f-f66f166c72e4",
    "createTimestamp": "2018-02-09T23:46:20.1847429Z",
    "itinerary": [
      {
        "name": "AdditionActivity",
        "address": "rabbitmq://localhost/Procedure.Service.Activities.AdditionActivity.Execute",
        "arguments": {
          "correlationId": "00000000-0000-0000-0000-000000000000",
          "first": 3,
          "second": 5
        }
      },
      {
        "name": "LogActivity",
        "address": "rabbitmq://localhost/Procedure.Service.Activities.LogActivity.Execute",
        "arguments": {
          "theLogMessage": "NewStyleConsumer - Consumed SomeFunMessage[924899da-7a61-4b80-819f-f66f166c72e4] - Procedure [924899da-7a61-4b80-819f-f66f166c72e4 has begun... - gonna trigger a routing slip!"
        }
      }
    ],
    "activityLogs": [],
    "compensateLogs": [],
    "variables": {},
    "activityExceptions": [],
    "subscriptions": []
  },
  "headers": {},
  "host": {
    "machineName": "TYLER-XPS13",
    "processName": "Procedure.Service.vshost",
    "processId": 13040,
    "assembly": "Procedure.Service",
    "assemblyVersion": "1.0.0.0",
    "frameworkVersion": "4.0.30319.42000",
    "massTransitVersion": "4.0.1.1390",
    "operatingSystemVersion": "Microsoft Windows NT 6.2.9200.0"
  }
}

我已经在此处阅读了文档(http://masstransit-project.com/masstransit/advanced/courier/(,但是没有什么是错的(除了命名某些事物的差异之外(在文档的代码样本和当前MT 4.0.1之间。

在MT 4.0.1中完成活动后,存储薪酬日志条目的正确方法是什么?和/或我可能做错了一些事情,即使我提供补偿日志价值,也表现为这种例外?

谢谢,

泰勒

看起来,您的ERSERDETATEHOST与Execute Activity主机相同的端点上注册,这导致在接收路由时导致两个主机被执行。

执行性host和redsearteactivityHost必须在单独的端点上(我猜您已经知道,但是在移植到4.0.1后,它们以某种方式将它们连接到了不正确的将它们连接到4.0.1(。

>

相关内容

  • 没有找到相关文章

最新更新