有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Java/Spring在线程关闭后为多租户程序获取租户?

我有一个Java/Spring(无Spring boot)程序,它基本上在前端加载后在ThreadLocal变量中设置tenantId,并执行其通常的多租户请求处理,这可能类似于本文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(查询在超时时触发,因此当前执行的线程可能真的是任何线程)。有没有办法在线程设置结束后仍然获取租户?请试着给出一个简单/高层次的答案,我不确定这个项目中的每件事实际上是如何实现的


共 (0) 个答案