java - Java / Spring在线程关闭后获取多租户程序的tenantId?
问题描述
我有一个 Java/Spring(没有 Spring 启动)程序,一旦前端加载,它基本上将tenantId 设置在 ThreadLocal 变量中,并执行其通常的多租户请求处理,这可能类似于本文https://medium.com /swlh/multi-tenancy-implementation-using-spring-boot-hibernate-6a8e3ecb251a:
1) Accept the incoming connection, and authenticate the user if necessary.
2) Intercept the request and identify the tenant for which the user is issuing the request.
3) Establish a connection with the database or schema of the tenant.
我的问题是程序在设置它的 ThreadLocal 变量的线程关闭后一段时间查询tenantId(查询在超时时触发,因此当前执行的线程可能真的是任何东西)。有没有办法在它设置的线程关闭后仍然获取tenantId?请尝试给出一个简单/高级的答案,我不确定该程序中的所有内容是如何实际实现的。
解决方案
推荐阅读
- python - 在我的 Pycharm CE 中找不到探查器选项
- reactjs - 如何调用路由路径 2,3,后跟 5,6,如果是 5,6,我应该重定向到另一个页面
- coq - 如何找到两个值之间的相等关系
- javascript - 将文本添加到 MapBox 标记
- python - corr() 函数的问题:nan 产生
- docker - 如何在 docker 环境中部署 Angular 应用程序
- java - 类作为另一个类中的实例字段
- python - 邮递员发出 JWT 令牌请求失败
- amazon-web-services - 我是 AWS Cloud 的新手,我正在为嵌套堆栈的概念而苦苦挣扎
- c++ - 您如何在语法方面使 std::variants 的使用更“可口”?