How is outbox going to work with two different databases?


(Alewmt) #1

Hi! I want to use RMQ, two different sql servers, outbox and no DTC between servers.
I didn’t get from the docs is it possible to have in the same process two different handlers for the same event, where every handler is going to access different database and publish events?


(Alewmt) #2

I looked at the source code. Am I understand correctly that NSB is intended to work with only one business data storage in a single process?

(Ramon Smits) #3

I wouldn’t advise accessing different data stores in a single endpoint. You are right that outbox can only work on one (transactional) data store at a time.

You can have multiple endpoints in a single process each having a different data store but it probably is easier and much better maintainable to have smaller endpoints.

All processing for a single message on a single endpoint should be considered as one unit of work. Accessing two independent data stores is breaking this unit of work because there is not shared (distributed) transaction that will guard consistency. Invoking multiple handlers in the same endpoint for the same message assumes all operate in the same unit of work

Alternatively do:

  • Have an endpoint for each data store, have each endpoint subscribe to this same event so each gets its own copy of the event for processing, or
  • Do not access both data stores in a single message/event but in separate messages
    • Send a local messages for each data store based on the received event (divide and conquer)
    • If there is a sequential dependency between the stores, update store A, then send a message that will update store B.

As outbox data must be stored in the same data store as your business data you must split these different stores among different endpoints.

Does that help?

(Alewmt) #4

yes, thanks. that is clear now