简体   繁体   English

有没有办法使用 RabbitMq 和 MassTransit 重启公交车?

[英]Is there a way to restart the bus using RabbitMq with MassTransit?

I want to restart the bus connection using RabbitMq with MassTransit, the first idea was to stop the connection and start it again but this did not work.我想使用 RabbitMq 和 MassTransit 重新启动总线连接,第一个想法是停止连接并重新启动它,但这没有用。 Is there something more specific or a better way to do that?有没有更具体或更好的方法来做到这一点?

await bus.StopAsync();
await bus.StartAsync(source.Token);

Assuming you are on a current version of MassTransit, you can do exactly that to restart the bus.假设您使用的是当前版本的 MassTransit,您完全可以这样做来重启公交车。

You can see in this unit test that the bus is started and stopped without issue.您可以在此单元测试中看到总线启动和停止没有问题。

await bus.StartAsync(TestCancellationToken);
await bus.StopAsync(TestCancellationToken);

await bus.StartAsync(TestCancellationToken);
await bus.StopAsync(TestCancellationToken);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MassTransit和RabbitMQ,使用DI时使队列在重新启动后幸存 - MassTransit and RabbitMQ, make queue survive restart when using DI MassTransit RabbitMq 巴士多次尝试启动 - MassTransit RabbitMq bus attempts to start multiple times 使用C#和RabbitMQ在MassTransit v3中实现仅发布总线 - Implementing Publish Only Bus in MassTransit v3 with C# and RabbitMQ MassTransit RabbitMQ AspNetCore 未启动总线并注册接收端点 - MassTransit RabbitMQ AspNetCore not starting the bus and registering receive endpoints 无法使用公共交通将消息发布到 rabbitmq - Unable to publish messages to rabbitmq using masstransit 如何与 MassTransit 使用 Rebus 创建的 Azure 服务总线主题互操作? - How to interop with Azure Service Bus topics created by MassTransit using Rebus? 使用 MassTransit 发布到 Azure 服务总线导致错误 - Publish to Azure Service Bus using MassTransit is causing errors 如何使用 MassTransit 从 RabbitMQ DeadLetter 队列中检索消息? - How to retrieve messages from RabbitMQ DeadLetter queue using MassTransit? 如何在RabbitMQ中设置多个队列并使用MassTransit 3连接? - How to setup multiple queues in RabbitMQ and connect using MassTransit 3? 在公共交通中使用消费者时,如何防止在 rabbitMQ 中自动创建交换? - How to prevent automatic creation of exchange in rabbitMQ when using consumer in masstransit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM