Cache solution jaxb - spring

I have a requirement in which I need to cache data coming as response from a soap ws. I am using Spring with JAXB and JAX-WS to call the web service. I am using ehcache for caching.
What I would want ideally is that the user data for example is cached as the java bean (JAXB). We can use the id of a bean (JAXB bean) as the name. Whenever data is requested, the data should first be checked in the cache and if the data is not available, the soap ws should be called and then the data should be stored in the cache.
I am not aware if there is already a solution to handle this in spring or ehcache or maybe in JAXB. Can someone please help me out.

In my view, the more important point to ask would be how would you keep the server data in synch with what you have cached on the client side? If you really want to do this, then you would have to create some sort of mechanism to notify clients that the original data has updated.
For e.g. one solution could be to create a JMS Topic (Pub/Sub) and have the server publish an event to this topic. All clients listen to this topic and reload the cache by making the web service call at this point.
In terms of the cache itself at the client end, why not just choose a ConcurrentHashMap to begin with?

Related

Spring Boot application with Redis cache without database

I am using Spring Boot application , I have below requirement.
I would like to cache all the rows from a particular table(here I have to convert the row into a particular xml format and maintain that in cache) and then also if any updates happens to that row by another application then in my application I will receive an message from Kafka topic. So I want to update the existing xml in the cache with the latest xml message from Kafka topic.
Here I want to use Redis cache, so far what ever the examples I saw are dealing with database only. So I want to know how I can populate cache from a Kafka topic message(or any xml message).Is it possible to cache an xml message in spring boot using Redis cache? Can some body share idea or any practical example?

Spring Integration with Spring Boot - High Availability

A spring integration project pulls emails from Exchange Server using imap-idle-channel-adapter; it transforms the message; it invokes some SOAP webservices and persists data in DB using Spring Boot and JPA. All works fine.
This needs to be deployed in a four-weblogic-server cluster environment.
Could someone please help with some hints on what needs to be done? Is there any configuration needed?
As long as your logic is just like you show and there is no any more endpoints polling shared resource, your are good so far do nothing more. The mail API has built-in feature to mark messages in the box as read or at least seen, so other concurrent session won’t poll those messages again.

How to use Apache Ignite as a layer between Spring Boot app and MongoDB?

I have a Spring Boot application that uses MongoDB. My plan is to store data in a distributed caching system before it gets inserted into Mongo. If the database fails, the caching will have a queue and send to the DB once it is up. So, the plan is to make the caching layer in between the application and Mongo.
Can you suggest some ideas on how to implement this using Apache Ignite?
Take a look at write-behind cache store mode. It retries writing to the underlying database if insertion to the underlying DB fails. Let me know how it works for you.
You can also implement a custom CacheStore for an Ignite cache that will do the caching and enable write through for it. If the connection is lost, then you'll be able to collect entries in a buffer, while retrying to establish the connection back.
See more: https://apacheignite.readme.io/docs/3rd-party-store

How to Restart Spring boot application (or just a particular instance of a class) when flyway migrate is ran or a new schema version is added

I have a particular instance of a class that loads some data from the database, so every time the database is updated the system should recreate the instance of that class to get the updated data
There are trivial several solutions:
(1) Use scheduling to load the latest data from DB periodically.
(2) Provide a web service such as RESTful API to load the latest data from DB.
(3) If your DB supports event-driven listeners, you can trigger your application to achieve this either by invoking a service described in (2) or send a message to queue and handle it by consumer.

communication between spring instances behind a load balancer

I have a few instances of Spring apps running behind a load balancer. I am using EHCache as a caching system on each of these instances.
Let's say I receive a request that is refreshing a part of the cache on one instance. I need a way to tell the other instances to refresh their cache (or to replicate it).
I'm more interested in a solution based on Spring and not just cache replication and that's because there are other scenarios similar with this one that require the same solution.
How can I achieve this?
There is no simple Spring solution for this. Depends on the requirements. You can use any kind of PubSub like a JMS topic to notify your nodes. This way the problem can be that you cannot guarantee consistency. The other nodes can still read the old data for a while. In my current project we use Redis. We configured it as cache with Spring Data Redis and theres no need to notify the other nodes since the cache is shared. In non cache scenarios we also use redis as a PubSub service.

Resources