[play-java-j2.5.x] Alternative solution for Thread Locals to propagate thread local values per request

36 views
Skip to first unread message

Joo Joo

unread,
Jul 21, 2016, 3:55:26 PM7/21/16
to play-framework
I am in middle of implementing a multi-tenant application in Play Framework 2.5.x Java Mongo.

I wanted to leverage Java  ThreadLocal values to set my clientId so that I can look up the correct database for client.

Seeminly ThreadLocal variables will not work due to adoption of Akka and Async operations for all request handling.

Is there any alternative approach to achieving this ?

Will Sargent

unread,
Jul 21, 2016, 5:06:04 PM7/21/16
to play-fr...@googlegroups.com
Play is stateless, so the best way to handle it is to keep that information in a very fast data store that is tied to the client id, and then pull that in when you need it.  

Will.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/55525758-a1cd-4596-812b-4b4731af8f35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Igmar Palsenberg

unread,
Jul 22, 2016, 3:22:32 AM7/22/16
to play-framework
 
Play is stateless, so the best way to handle it is to keep that information in a very fast data store that is tied to the client id, and then pull that in when you need it.  

If you want raw speed to the max, I can recommend ScyllaDB (http://www.scylladb.com). It's cassandra compatible, but with some great speed advantages. Oh, the code is also nice to read :)


Igmar 
Reply all
Reply to author
Forward
0 new messages