0

Let's say there is service bus instance working in one way mode. The service bus generates two kinds of messages: Foo and Bar. Both of these message types are to be saved in database.

So I can see two approaches for doing so:

  1. Have two queues (FooQueue, BarQueue) and two bus instances (two processes) - one for receiving from FooQueue and one for receiving from BarQueue

  2. Have one queue and one bus instance with two handlers for Foo and Bar messages

I would like to ask what are best practises (maybe even decision tree? :) ) for deciding when to use which approach.

Thanks in advance

user1121956
  • 1,843
  • 2
  • 20
  • 34
  • To start off with it may not matter to have a single endpoint handle both messages from a single queue. However, it should be pretty simple to install the endpoint as another instance and, using configuration, split the message processing between the two endpoints / queues using routing. I have run into this exact scenario where we ended up needing priority processing for messages from a front-end and more of a long queue for back-end processing. – Eben Roux Sep 17 '14 at 18:18

1 Answers1

1

Well.... in your case, it sounds pretty much like the surrounding infrastructure (i.e. database connection string, datalayer API) as well as the problem domain ("saving messages to the database") are shared among the two message types - it doesn't sound like they're going to be handled differently - which, to me, sounds like it makes all kinds of sense to have a single endpoint that receives & saves the messages.

In fact, you can do with a single handler that implements IHandleMessages<object> if you know that the endpoint only gets to receive messages that must be saved.

mookid8000
  • 18,258
  • 2
  • 39
  • 63