I'm using Rebus and I want to introduce something like described in CQRS Journey at paragraph "Avoid processing events multiple times", but I cannot figure it out.
I configured Rebus to use SQL Server for Transport and MongoDB for Subscriptions and Sagas. The Routing is configured TypeBased and maps all the commands handlers' types to the queue configured in Transport.
var bus = Configure.With(new SimpleInjectorContainerAdapter(container))
.Logging(l => l.Trace())
.Transport(t =>
{
t.UseSqlServer(connectionstring, "TestMessages", "messageQueueName");
})
.Routing(r => r.TypeBased()
.MapAssemblyOf<Assembly1.Commands.DoSomething>("messageQueueName")
.MapAssemblyOf<Assembly2.Commands.DoSomethingElse>("messageQueueName")
)
.Sagas(s => s.StoreInMongoDb(db, (sagaType) =>
{
return sagaType.Name;
}))
.Subscriptions(s => s.StoreInMongoDb(db, "Subscriptions"))
.Options(o =>
{
o.SetNumberOfWorkers(1);
o.SetMaxParallelism(1);
o.EnableSagaAuditing().StoreInMongoDb(db, "Snapshots");
})
.Start();
Now I should configure Rebus in a way that when a command Publish an event, this is replicated in as many separate topics (virtual or physical queues) as existing subscribers' types.
Something like:
bus.Subscribe<Assembly1.EventHandler1>("Assembly1.EventHandler1Queue").Wait();
bus.Subscribe<Assembly1.EventHandler2>("Assembly1.EventHandler2Queue").Wait();
bus.Subscribe<Assembly2.EventHandler1>("Assembly2.EventHandler1Queue").Wait();
Thanks for help.
azure-servicebus-topics
and you are referencing an article on how to use (among other things) Azure Service Bus topics to implement pub/sub.... but you have configured your bus to use SQL Server as its message queue - is that intentional? – mookid8000