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).
I have one producer of Tasks to do, lets say ImportOrder and CalculateOrderPrice
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="[email protected]"/>
</endpoints>
Configure.With(adapter)
.Logging(l => l.Log4Net())
.Transport(t => t.UseMsmqAndGetInputQueueNameFromAppConfig())
.MessageOwnership(d => d.FromRebusConfigurationSection())
.CreateBus()
.Start();
adapter.Bus.Subscribe<RecalculateContractMessage>();
I cant seem to configure this setup, it does not really matter if I use msmq or sqlserver.
I'll answer your questions one by one:
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.
In this case, it sounds to me like you're in need of a competing consumers type of distribution of your tasks.
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.
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.
It should be fairly easy for you to get started by looking at the posts and use e.g. SQL Server as your transport.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With