NServiceBus Pub/Sub example and the "Distributor"
I finished going through the example of Pub/Sub for NServiceBus.
I am now trying to wrap my head around the "Distributor" concept of 开发者_开发问答NServiceBus.
At first I was very confused because I thought there was some part of the example that mapped to a "Distributor". I am now starting to think that is not the case.
So, the example shows 2 moving parts. A Publisher and a Subscriber. But the next page shows at least 4 moving parts.
- Subscription Database
- Publisher Node (P_1, P_2)
- Distributor
- Subscriber Node (S_A_#, S_B_#)
It was all making a lot of sense until I got to this point. Now I am left wondering how these new players map to the nice clear example. (Or is there a new example I should be looking at?)
I read the pages about these, and it all makes sense from a conceptual point of view. But I don't see how it works in real life/code/example.
In case I am being too vague in my question, let me ask a more specific one: What would I need to do to the Pub/Sub example to make it use the 4 parts above?
If you take the basic Pub/Sub sample you need to add a few more endpoints to the mix. Each Distributor endpoint will hold the messages from the Publisher. "Behind" each Distributor will be a set of Subscribers that will also behave as Workers(you need to add the Distributor config). Each set of Subscribers behind a distributor will be identical. Once the Distributors receive work from the Publisher and they will distribute the messages amongst the Subscribers.
To set this up I would add 2 Distributors to the sample and put Subscriber 1 behind one Distributor and Subscriber 2 behind the other. First make sure that all works. Then spin up another instance of each(pointing to their respective Distributors) so you can watch them load balance. In the end, you will have one Publisher, two Distributors, and 4 total Subscribers. From there you could add another Publisher to complete the picture.
精彩评论