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 - spring-boot

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.

Related

Cache refresh on spring boot whenever Data update happens in Database from third party application also(Update will not happening by our application )

I need to refresh my Cache as soon as DB changes happened ,update might happen to DB from another source also not from my application in MySql. How can I do that as mysql will not provide access to call java method as part of TRigger as like in Oracle? (SpringBoot application)

Spring Boot: how to implement workflow as synchronous REST services integrating external applications

I'm here to ask you for a suggestion on which technology to use to add new features on an existing application based on Spring Boot.
The new features consist of some workflows, exposed as synchronous REST services, that must update the database and call REST services exposed by external applications, which consequently will update their own database.
For example, a service could implement this workflow:
insert rows in database
call the REST service of the application X, which will update its database
update rows in database
call the REST service of the application Y, which will update its database
update rows in database
This workflow must be synchronous and it is started from an human operator that will receive the outcome in few seconds.
If, for example, the step 4) fails, I need to:
make a compensation, calling another REST service of the application X, in order to undo what it made in step 2)
rollback the insert/update made in my database in steps 1) and 3)
Which technology, framework, tool or other would you use? In the past I implemented a similar scenario using Oracle SOA, but in this case I would avoid to introduce a new infrastructure in my application based on Spring Boot.
Thank you
I guess you need to learn a bit more about Spring Framework and Spring Boot.
1.insert rows in database : Spring Data JPA
2.call the REST service of the application X, which will update its database : A Http Client such as RestTemplate or WebClient
3.update rows in database : Spring Data JPA (again)
4.call the REST service of the application Y, which will update its database update rows in database : RestTemplate...
So so and so...
If you want to make a real workflow, you can use Activiti.

AxonIQ AxonFramework MongoEventStorageEngine framework table creation on business DB

I am using AxonIQ AxonFramework version 4.5.3 with Spring Boot and custom event store.
I'm using MongoEventStorageEngine and configured a separate MongoDB database for the EventStorage.
I am doing some business logic with my business database through a microservice. In the same microservice, I've configured the custom EventStorage.
But a few tables (viz. association_value_entry, saga_entry, token_entry) are getting created on my business database which is a PostgresDB.
Why is AxonFramework creating new tables in my business database as I have already configured a separate MongoDB database for EventStorage. All the related database objects for Axon to work should be ideally created in the EventStorage database rather than in my business database.
The tables you are mentioned should be part of your 'read' model (I believe that is what you called business database).
They are not used for Event Storage or Event Sourcing but rather to specific things that are controlled on client side. For example, token_entry, among other things, is the table where your app keep track of the tokens and events it already consumed - you can read more about it here. Similar to the saga tables, where Sagas are stored on the client side having nothing to do with the Event Store - you can read more about it here.

Parallel processing in multiple instances of spring boot application

I am not able to analyse, how to go ahead. I am using Spring boot 2, Oracle, IBM MQ.
I have made 2 async requests to external applications. I need to do some operation when I have received both of the responses.
I am not able to set it up as there are multiple instances of application running and listening to same queue for response.
I tried using #transactional and cyclic barrier. But I guess they will work only in scope of their own instance and not between multiple instances.
How should I proceed ahead?
It is also really difficult to reproduce the scenario where one message is read by one instance and other by other instance that too at the same time, where they eventually try to update db at same time.

Cache solution jaxb

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?

Resources