【问题标题】:compensate transaction when one of the activities not consume command at the specified time in Mass Transit当其中一项活动在公共交通中的指定时间没有消耗命令时补偿交易
【发布时间】:2020-08-01 16:14:43
【问题描述】:

我正在尝试在多个服务之间创建分布式事务。为此,我正在使用公共交通框架 - 快递功能和 RabbitMQ。我的路由单配置是:

public class RoutingSlipPublisher
{
    private readonly IBusControl _bus;

    public RoutingSlipPublisher(IBusControl bus)
    {
        _bus = bus;
    }

    public async Task<Guid> PublishInsertCoding(Coding coding)
    {
        var builder = new RoutingSlipBuilder(NewId.NextGuid());

        builder.AddActivity("Core_Coding_Insert", new Uri($"{RabbitMqConstants.RabbitMqUri}Core_Coding_Insert"));
        builder.AddActivity("Kachar_Coding_Insert", new Uri($"{RabbitMqConstants.RabbitMqUri}Kachar_Coding_Insert"));
        builder.AddActivity("Rahavard_Coding_Insert", new Uri($"{RabbitMqConstants.RabbitMqUri}Rahavard_Coding_Insert"));
        builder.SetVariables(coding);
        var routingSlip = builder.Build();
        await _bus.Execute(routingSlip);
        return routingSlip.TrackingNumber;
    }
}

问题:Kachar_Coding_Insert 消费者在指定时间内未连接到 RabbitMQ 时,我想要补偿交易。但这不会发生,并且在 Kachar_Coding_Insert 消费者连接到 RabbitMQ 并执行活动之前,事务还没有完成。 你如何解决这个问题?

【问题讨论】:

    标签: asp.net-core rabbitmq masstransit distributed-transactions saga


    【解决方案1】:

    Courier 没有集中编排,路由单是真相的来源。如果路由单在队列中等待某个活动执行,并且该活动不可用,则路由单将保留在该队列中,直到服务启动。

    没有任何方法可以改变这种行为,您的传送单活动服务应该可用。您可能希望监控您的服务以确保它们正在运行,似乎所需的活动服务不可用将是一种不健康的状况。

    【讨论】:

      猜你喜欢
      • 2021-02-10
      • 2015-08-27
      • 2015-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多