This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to update spring cache when using spring data repository

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to implement a replicated cache in a spring managed distributed application using activemq (jms). Multiple instances of the application server should update their copy of the cache when one of them triggers a change. I am trying to implement a standalone application to mimic this.

I have a spring boot rest application that uses spring data's CrudRepository. I have enabled caching by adding the @Cacheable annotations.

How can I update this cache that is managed by spring through some custom code? There are two events when update is required

1. When the save method is called I would like to execute the jms producer code to push the java object (Person) on a jms topic. How can I add custom behavior to call the jms producer code after saving the java object in the save method?
2. Update the cache (myCache) in the jms consumer code. How can I get a handle to this cache in the spring data repository external to this interface in order to so?

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
    Bookmark Topic Watch Topic
  • New Topic