Masstransit UseInMemoryOutbox 无法与 MultiBus Saga 配合使用?
我实现了一个自定义活动来支持多总线传奇。 但我发现一个问题,即在状态传奇保存到 Redis 之前,我收到了来自 SecondBus
的已发布消息。 我认为 UseInMemoryOutbox()
应该处理这个问题,否则我错了。
public class TestActivity : Activity<SagaState, IFirstBusRequest>
{
private readonly ISecondBus _secondBus;
public TestActivity(ISecondBus secondBus)
{
_secondBus = secondBus;
}
public async Task Execute(BehaviorContext<SagaState, IFirstBusRequest> context, Behavior<SagaState, IFirstBusRequest> next)
{
var endpoint = await _secondBus.GetSendEndpoint(new Uri($"queue:second-bus-request"));
await endpoint.Send(new { }); // send immediately
}
}
I implemented a custom activity for supporting multibus saga.
But I found an issue that is I received a published message from SecondBus
before the state saga saves to Redis.
I think UseInMemoryOutbox()
should handle this or i wrong.
public class TestActivity : Activity<SagaState, IFirstBusRequest>
{
private readonly ISecondBus _secondBus;
public TestActivity(ISecondBus secondBus)
{
_secondBus = secondBus;
}
public async Task Execute(BehaviorContext<SagaState, IFirstBusRequest> context, Behavior<SagaState, IFirstBusRequest> next)
{
var endpoint = await _secondBus.GetSendEndpoint(new Uri(quot;queue:second-bus-request"));
await endpoint.Send(new { }); // send immediately
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确,这是一个已知的限制,因为另一个总线实例是完全独立的总线,并且不是接收总线上发件箱的一部分。
如果您需要涉及发件箱,请考虑在第一条总线上生成消息,并在该总线上有一个使用者,仅将该消息转发到另一条总线。
然后,您可以只拥有一个带有这些消息转发器的端点:
然后,
ConfigureEndpoints
会将这些使用者置于接收端点上,该接收端点会将这些消息转发到其他总线实例。Correct, it's a known limitation since the other bus instance is a completely separate bus, and isn't part of the outbox on the receiving bus.
If you need to involve the outbox, consider producing the message on the first bus, and have a consumer on that bus which only forwards that message to the other bus.
You could then just have an endpoint with those message forwarders on it:
And then,
ConfigureEndpoints
will put those consumers on a receive endpoint that will forward those messages to the other bus instance.