Hello, There is a servlet container with many concurrent users. Each user request works in its own thread from pool (tomcat is used) There is also ApacheMQ server that routes messages for users via JMS.
To send message to user Mary you need to use topic "users.Mary". So, web server subscribes to this topic when user logs in and unsubscribes when user logs out. There are too many users and only few of them are logged into server, so we can't simply subscribe to "users.*": that would lead to millions of useless messages travelling over network. Each time user refreshes page, we need to display her all messages she got from last time page was refreshed. We have 2 ideas: * Use one Connection and one Session for the whole web-app, create consumer for each user and store it in user session. Each time user opens page we do receiveNoWait and obtain all messages she got. * Fetch all messages from all consumers on background thread and store them in collection, so each request would get them. I like the first one, but I am not sure accessing one Session from different threads is good idea. What do you think? Ilya Kazakevich
