Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to update spring cache when using spring data repository

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?

Thanks.
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this 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
    Bookmark Topic Watch Topic
  • New Topic