我应该如何为一个生产商和许多消费者设置重新营销 [英] How should I set rebus up for one producer and many consumers

查看:75
本文介绍了我应该如何为一个生产商和许多消费者设置重新营销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览示例并阅读文档,但是我仍然不确定如何为我的场景配置rebus(或者使用总线很合适).

I am going through the samples and reading the docs but I am still not sure of how to configure rebus for my scenario (or that using the bus is a good fit).

我有一个Tasks的生产者可以做,比如说ImportOrder和CalculateOrderPrice

I have one producer of Tasks to do, lets say ImportOrder and CalculateOrderPrice

我想转储来自生产者的消息并将这些消息排入队列. 我想要两个侦听ImportOrder的客户端,以及10个侦听CalculatePriceOfOrder的客户端.我不希望同一订单同时进入多个端点,我想分散工作量.

I want to dump messages from the producer and queue lots of these messages. I want two clients that listens to ImportOrder, and 10 clients that listens to CalculatePriceOfOrder. I do not want the same order to go to multiple endpoints at the same time, I am trying to spread the workload.

到目前为止的制作人配置:

Producer config so far:

 <rebus inputQueue="publisher.input" errorQueue="publisher.error" workers="1" maxRetries="5">

var adapter = new BuiltinContainerAdapter();
            Configure.With(adapter)
                   .Logging(l => l.Log4Net())
                        .Transport(t => t.UseMsmqAndGetInputQueueNameFromAppConfig())
                        .Subscriptions(s => s.StoreInXmlFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "rebus_subscriptions.xml")))
                        .MessageOwnership(d => d.FromRebusConfigurationSection())
                        .CreateBus()
                        .Start();

到目前为止的消费者配置:

Consumer config so far:

<rebus inputQueue="calcserver1.input" errorQueue="calcserver1.error" workers="1" maxRetries="5">
<endpoints>
  <add messages="Messages.RecalculateContractMessage,  Messages" endpoint="publisher.RecalculateContract@se-devws-0007.sirius.local"/>
</endpoints>

Configure.With(adapter)
               .Logging(l => l.Log4Net())
                .Transport(t => t.UseMsmqAndGetInputQueueNameFromAppConfig())
                .MessageOwnership(d => d.FromRebusConfigurationSection())
                .CreateBus()
                .Start();

        adapter.Bus.Subscribe<RecalculateContractMessage>();

我似乎无法配置此设置,是否使用msmq或sqlserver都没有关系.

I cant seem to configure this setup, it does not really matter if I use msmq or sqlserver.

  • 在这里,rebus(或任何服务总线类型的解决方案)听起来很合适吗?
  • 我应该使用pub/sub还是纯发送模式?这种选择是否会影响消息是否仅在一个时间点或几个时间点被处理?
  • 有人能给我指出一个好例子或解释如何设置这种情况吗?

推荐答案

我将一一回答您的问题:

I'll answer your questions one by one:

  • 在这里,rebus(或任何servicebus类型的解决方案)听起来很合适吗?

是的,服务总线可以帮助您处理很多事情,这些事情本来是您必须自己处理的.

Yes, a service bus can help you deal with lots of stuff (e.g. serialization, threading, etc.) that you would otherwise have to somehow handle on your own.

  • 我应该使用pub/sub还是纯发送模式?这种选择是否会影响消息是否仅在一个时间点或多个时间点被处理?

在这种情况下,听起来像您需要竞争消费者您的任务分配类型.

In this case, it sounds to me like you're in need of a competing consumers type of distribution of your tasks.

这不是pub/sub - pub/sub表示每个消息 instance 的0 .. *使用者,但是您希望每个任务一个确切的收件人.因此,在这种情况下,您将bus.Send任务.

This is NOT pub/sub - pub/sub implies 0..* consumers for each message instance, but you want exactly one recipient for each task. Therefore, you would bus.Send the tasks in this case.

  • 有人能给我指出一个好例子或解释如何设置这种情况吗?

我写了几篇博客文章,通过不同支持的传输的示例,展示如何使用Rebus扩展工作量的处理.

I've written several blog posts in an attempt to show how you can scale out the handling of your workload with Rebus with examples for the different supported transports.

通过查看帖子并使用例如SQL Server作为您的传输方式.

It should be fairly easy for you to get started by looking at the posts and use e.g. SQL Server as your transport.

这篇关于我应该如何为一个生产商和许多消费者设置重新营销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆