How to send rest request for only particular records in a Oracle database table using Spring Boot - spring

I have created a simple service using Spring Boot. There is a table Message_Queue as shown in this image link -
Message_Queue Table
I am using oracle database. Here, msisdn is a number which is primary key, and it has some other fields like sim_number, activation_date, subscription_id.
There is another Spring Boot service which sends rest API request to add the activation_date and subscription_id details for the respective record in message_queue table. Table message_queue holds data upto 2 million records.
I want to create a scheduled task in my Spring Boot application, which will send rest API request to some other 3rd service only for those records which has activation_date and subscription_id details filled and will also delete that record from the table.
What is the best way to achieve that using Spring Boot framework? Please try to answer on the enterprise level standards.
Is it a good approach to fetch like 1000 records with pagination until all the records are not checked from the table and then check for each record if it has activation_date and subscription_id or not, if it has then send a rest request for the record and also a delete request to the DB for the same record?

Related

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.

How to make Spring Data JPA and MongoDb multi-tenant at the same time?

I am using Spring Data JPA and MongoDb in my rest application. My database structure is such that for each Customer type, we have a separate oracle and mongodb. Whenever a Customer makes an http request to my rest server, based on some request header parameter i determine the customer type.
For instance, for Customer type A, there will be an "Oracle database A" and "Mongo database A". Similarly there will be "Oracle database B" and "Mongo database B" for customer type B and so on. The number of Customer types are fixed.
Now what i want is, suppose if Customer B makes an http request, then for this particular thread, all oracle hits should go to Oracle Database B and all mongo hits should go to Mongo database B.
I am aware of AbstractRoutingDataSource for making JPA multi-tenant but cannot think of a way to make both MongoDb and Oracle multi-tenant at the same time.

Spring boot unique id for every transaction

I have the following use case -
The user fills up a form.
The spring boot backend code calls multiples services before pushing the user data to the database.
The database takes more than 10 secs to commit the details
Since the whole process takes time, I want to return a transaction id to the user immediately after he fills up the form. The user can check the status later using the same transaction Id.
Does spring boot provide any feature to achieve this?

Spring Realtime Data Sending With Database

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

Resources