I have a webapp using spring/hibernate. This has 2 tasks, serve REST calls, and also listen on message queue, and insert into DB.
I implemented MultiTenantConnectionProvider interface and CurrentTenantIdentifierResolver and
My bean which returns the current tenant (called by CurrentTenantIdentifierResolver) has WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.INTERFACES
Now, when i send REST call, my tenant gets set fine and data is returned.
When a message arrives on my queue, i tried using JPA to save(object), but getting error since the tenant is not set.
If i set my bean to :SCOPE_SINGLETON , then when i get message on my queue, i can insert properly, since i can manually set my bean's tenant value. But my REST call won't work, since i can
get parallel REST queries..
How do i solve this.. Appreciate any help.