• 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 ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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.

ApplicationListener.java


Controller method for pushing the message to the subscriber

 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic