• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Instance list behaves as a global list

Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic