Hi,
Based on ABP documentation for Background workers (https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#background-workers), I am wondering how is the most convenient way for running the same worker on all databases (tenant databases)?
- Make one instance of background worker and inside worker switching between database contexts (tenant databases) or
- Make an instance of background worker for each tenant on application startup and somehow inject tenant to background worker instance?
I have strictly separated databases for each tenant and none is using a host database.
Thank you for explanations.
4 Answer(s)
-
0
for the sake of code duplication, my choice would be writing one background job and iterate thru tenants.
-
0
Sorry for late reply.
https://aspnetboilerplate.com/Pages/Documents/Abp-Session?searchKey=abpsession#overriding-current-session-values
Is changing tenantId database context also works inside using block?
using (_session.Use(42, null)) { //correct database context (connection string) for explicitly defined tenantId if this tenant has dedicated database (not using host database)? }
-
0
using block will overwrite the session.tenantId value in the specified block.
-
0
including connection string or just tenantid value?