Spring Realtime Data Sending With Database - spring-boot

I'm having small e-commerce application with Spring boot, but I want to realtime the rest endpoint where the products are listed, so I want the rest endpoint to be updated if any product is updated or created.
I'm confused how to listen database in realtime. I found Sse for realtime data sending but i couldn't found how to do this with database
Can you please suggest a best methodology

If you are using Hibernate for managing Data. then use hibernate envers and process the model after create/update db.
my suggestion is whenever an action create/update happens in hibernate.
Hibernate envers will trigger and use Akka actor to process the event.
Hibernate -> hibernate Envers -> Akka (business layer) -> rest endpoint
Thanks,
Vimalesh

Related

Need to update multiple collection of cosmosdb with spring boot. How to manage the transaction. If anything failed all should be rolled back

How to handle transaction using spring boot and cosmosdb. For example write has to made in mutiple collections, if anyone of them fails then all should be rolled back. It is written in this link that its possible with version 4 api.
How to handle Transaction in CosmosDB - "All or nothing" concept
Any integration example will be helpful.

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 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.

Can we use Couchbase as the message store for Spring Integration

We are implementing Spring Integration aggregator and using JDBC message data store. In our environment we have Couchbase and Oracle DB. I don't want to use Oracle DB, can we use couchbase as the message store.
If yes, can you please suggest the approach.
There is a MessageStore strategy that you would need to implement and then configure as any other message store in your Spring Integration components that required it. Here is a bit more info.

How to handle multiple kafka topics with springboot app?

I’m implementing RestFul api using spring boot application. Based on the requester, I need to pick the topic and get the data from that topic.
Let say if I hit url requester1/data then I should get data from topic1 and if I hit the url requester2/data then I should get the data from topic2 and so on.
So how to handle these multiple topics in the spring boot app and get data from a particular topic when I get the request?
Well. you should inject a ConsumerFactory<?, ?> into your RESTFull service and use a KafkaConsumer API directly.
Any existing KafkaMessageListenerContainer architecture in the Spring Kafka is long-lived, event-driver implementation it can't be adjusted at runtime to perform consumption on demand. That's exactly for what KafkaConsumer exists.

Resources