Im trying to figure out how exactly outbox is suppose to work with NServicebus but I'm not quite sure I get it. Here is the current scenario that we have:
Service1 Service2 Service3 ServiceN
Each of the services has its own database where it holds business data and servicebus shared database used for queue/message broker.
This means that each of these services is using the same connection string for servicebus and has different connection string for business database.
The problem we are facing is that saving into business database and publishing is technically saving into 2 databases, so this will create distributed transaction if wrapped into transaction.
Now, Im considering implementing outbox pattern to solve this problem, but NServiceBus documentation doesnt really give us an idea regarding this question:
By enabling outbox NServiceBus indeed creates new table for holding messages servicename_Outbox table, but should it be stored into Servicebus database or business data database? If its stored in servicebus database then, technically to save data into it it still needs distributed transaction?
Where should Outbox table be stored? Is it suppose to be stored in a same database as bussiness data?
Yes
Where will the subsciption data be stored in this case for given service?
If you use message driven pubsub instead of native pubsub then yes.
Is it possible to configure NServicebus to create outbox table into bussiness database while the rest of the tables are created in service bus database?
Yes, that is expected.
but should it be stored into Servicebus database or business data database? If its stored in servicebus database then, technically to save data into it it still needs distributed transaction?
Outbox data is stored in the business database and share the same storage connection/transaction so does not require a distributed transaction.
How does servicebus know which table to pool for Outbox pattern and to dispatch messages?
Each endpoint has its own entity.
Can this be explicitly configured?
Please check the outbox configuration for the persister that you are using to see if the table name van be configured: