How to configure different table names in NserviceBus/Persistence SQL instance

nservicebus
nhibernate

(Muthukumar Pl) #1

We are planning to share the same persistence database( NserviceBus/Persistence) between multiple NSB hosts.

In that Case, we need to have different table names for TimeOutEntity, MessageStore, OutboxRecord
to disntinguish based on hosts.

Is there a way of configuration to specify the table names for a host to use in the NSB Persistence database.


(Hadi Eskandari) #2

As already suggested here you’re better off using schemas instead.

You didn’t specify exactly which transport/persistence you’re using?


#3

What you are describing is the primary reason I switched from the NHibernate persistence to the SQL Persistence. You have so much more flexibility.

  1. I use a common schema for all NServiceBus persistence named… you guessed it NServiceBus
  2. You can prefix the table names for the endpoint.
    options.TablePrefix(FormattableString.Invariant($"{nameParts[0]}{nameParts[1]}"));

So If You have an endpoint named “Notification.Server”, it’s persistence tables would all be “nservicebus.notification_server_xxx”. This would be true for outbox, timeout, and sagas. It makes it very easy to distinguish between them and keeps everything in the same schema location for ease of lookup, etc.