MassTransit-用于内存中使用

发布于 2025-02-06 21:59:35 字数 1064 浏览 3 评论 0原文

我从MassTransit开始,用于出版商/消费者的情况。在生产中,我们将使用SQS,但是我希望能够在本地使用“内存”进行开发。

我在为isendendPointProvider.getSendenpoint()的呼叫组建正确的URI时遇到了麻烦,请注意:

//THE SET UP CODE:
x.AddConsumer<MTConsumer, MTMessageConsumerDefinition>()
    .Endpoint(e =>
    {
        // override the default endpoint name
        e.Name = "process-input-item";
        //... more configurations as per docs here...
    })
    ;
    x.UsingInMemory((context, cfg) =>
    {
        cfg.ConfigureEndpoints(context);
    });
});


//The Publish Code:  
  var endpoint = await SendEndpointProvider.GetSendEndpoint(new Uri("/ProcessInputItem"));
  await endpoint.Send(new MTMessage { InputItemId = item.Id});

注意

  • 我尝试了端点字符串的各种情况。
  • 我不想捕获ibus的实例来调用发送,因为这不是与消费者的“最接近”实例,根据文档,这一点很重要。

大众运输文件参考: https://masstransit-project.com/usage/usage/configuration .html#接收 - 端点

谢谢您对此的任何

指导

I am beginning with MassTransit, for a publisher/consumer scenario. In production we will be using SQS, however i would like to be able to use "In Memory" for development locally.

I am having trouble with forming the correct Uri for the call to ISendEndpointProvider.GetSendEnpoint(), as per:

//THE SET UP CODE:
x.AddConsumer<MTConsumer, MTMessageConsumerDefinition>()
    .Endpoint(e =>
    {
        // override the default endpoint name
        e.Name = "process-input-item";
        //... more configurations as per docs here...
    })
    ;
    x.UsingInMemory((context, cfg) =>
    {
        cfg.ConfigureEndpoints(context);
    });
});


//The Publish Code:  
  var endpoint = await SendEndpointProvider.GetSendEndpoint(new Uri("/ProcessInputItem"));
  await endpoint.Send(new MTMessage { InputItemId = item.Id});

Note

  • I have tried the various cases for the endpoint string.
  • I do not want to capture the instance of IBus to call Send as that is not the 'closest' instance to the consumer, which according to the docs is important to consider.

Mass Transit document reference: https://masstransit-project.com/usage/configuration.html#receive-endpoints

Thank you for any guidance with this,

Dylan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍风燃霜 2025-02-13 21:59:35

在文档中解释了用过的。在您的情况下:

await SendEndpointProvider.GetSendEndpoint(new Uri("queue:process-input-item"));

As explained in the documentation, there are short endpoint addresses which can be used. In your case:

await SendEndpointProvider.GetSendEndpoint(new Uri("queue:process-input-item"));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文