ramsrib / multi-tenant-app-demo

Demonstrates the discriminator field (shared schema) based multi-tenant application using Spring Boot & Hibernate 5.
69 stars 26 forks source link

How do we pass tenantId info when we are switching thread #5

Open SubhamSinghal opened 3 years ago

SubhamSinghal commented 3 years ago

TenantId is stored in a thread local variable. Now if we switch thread either by using ExecutorService or Vertx event then how can we pass tenant info to other thread?

paksboda commented 3 years ago

You can use decorator pattern to pass your thread context to new threads. https://stackoverflow.com/questions/45890181/logging-mdc-with-async-and-taskdecorator