• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating a list for the clustered environment

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application there is a list publisherPostListenerList which receives the real time user posts from the RabbitMQ queue to be sent to the subscribers/consumers. The list is a property of ApplicationListener class which listens to the events of the pubsub queue. The below controller method fetches the list elements via getter method & based on a logic pushes the posts to the subscribers.

The flow is as follows

User writes a post -> Post gets into DB + Queue -> Message from Queue is added in a list which is publisherPostListenerListto be pushed to the subscribers of the user.

As we can see the publisherPostListenerList is a common list for n concurrent requests due to ApplicationListener being a singleton. For a single instance the setup works fine but will fail in a clustered environment as each node will have its own individual publisherPostListenerList list.

How do I deal with this situation? I can't make ApplicationListener class stateless I need the list to store the post elements received from the queue. Do I put the list in a distributed in memory cache? Or there is any other conventional way?

ApplicationListener.java




Controller method for pushing the message to the subscriber

 
reply
    Bookmark Topic Watch Topic
  • New Topic