I have a publish subscribe queue message listener method which fires an event when it reads a message in the queue & adds the message to a publisherPostListenerList in the ApplicationListener class.
The messages added in the list are being pushed to multiple subscribers like real time notifications from the controller method.
After pushing the message to a respective logged in user I am removing the message from the list to avoid the push of redundant message to the user also it keeps in check the size of the list.
The problem is there is only single instance of publisherPostListenerList for all the logged in users. The list being an instance list there should be a separate copy for every logged in user but its not the case. Please correct me if I am wrong.
If I delete a message it deletes the message from the publisherPostListenerList for all the subscribers.
Now my questions are
1. Shouldn't there be an individual copy of publisherPostListenerList list for every logged in user, the list being an instance list.
2. How do I create a separate copy of list for all the logged In users
P.S. I tried changing the bean scope to prototype but didn't work.
Below is the ApplicationEventListener class which holds the list & the controller code.
Controller method for pushing the message to the subscriber