I am using Spring Boot for creating Microservices. I have implemented a common library (jar) where other Microservices uses it for security and validation purposes. I have a requirement to have on common functionality where it requires DB connection.
I have planned to use the same common library to implement, but to supply the DB details, each Microservice using this common library has to configure the DB details in its corresponding application.properties. I wanted to know is this right approach of asking individual microservice to supply DB details in a agreed property names and it can be used by library ?
Another option I think is to implement it as a another Microservice and other Microservices can invoke using RestTemplate. But I don't want to do this as it is a simple functionality.
Related
I have a java spring boot application that runs a job to upload data to Database after polling a message from SQS and this application also contains a REST API over that same database.
Now I need to decouple the upload functionality and REST API.
Upload functionality would be done by an AWS Batch Job which would be triggered by a lambda.
Rest API would be simply as it was before.
Challenge is that I need to do all these operations within the same code repo. This is to avoid having 3 repositories one for REST API, another for the AWS Batch Job, and the last for AWS lambda handler.
Thus trying to find out solutions that spring boot can provide to run a same application in different modes. Please help.
I won't recommend using Spring Boot for lambda - technically you can, but it's waste of money. Spring Boot is overhead for java, it requires more memory, so it's more expensive.
You need to create a multi-module Maven application. The modules would be:
Existing Spring Boot app.
Batch job.
Common code, used by modules 1 & 2.
Simple new lambda.
... more modules if you need ...
But if you still sure that for some reason you want to wrap existing Spring Boot app into lambda, this library would help you:
https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot
I am learning vertx framework with Java, and I was wondering if there is any "framework" such as Spring Core to perform dependency injection or a library ?
And also, I was looking for an ORM to interact with a Relational Database (eg. Hibernate, Spring Data in Spring.
Thank you for you recommendation !
You can use an integration between Spring and Vert.x in your project:
You can see examples here:
https://www.baeldung.com/spring-vertx
https://github.com/vert-x3/vertx-examples/tree/master/spring-examples
The general idea is to use Spring for configuring your application and use all its powerful annotations and dependency injection features and use Vert.x for for creating http server to handle your requests using Vert.x reactive model.
But if you find yourself writing all your code for handling requests inside an executeBlocking (for example, if you are using Spring Data and all your requests retrieve from DB) please don't do that. Instead try to find alternative asynchronous ways for doing things (for example, for DB you can use Vert.x async clients).
I'm new to WEB SOA applications and i have several questions about how to implements this architecture.
I would like to make a SOA based application involving multiple services using spring restfull api.
I'm aware of how to build each service itself.
i've already made a maven based project exposing a restful service using spring boot and secured it using spring security... my problem is to implement several services:
I don't know if i have to make a project for each one or there's a better solution... i want them to communicate through XML/Json so they won't be in same project in my point of view.
All secured by same service which makes use of spring security, i don't know how to link between the security service and the other ones. i don't want to write same security config classes on each project and then the user would be asked for sign in each time he accesses one of the services.
Share some resources which are used by all most services such as domain model classes, since i don't want to copy paste them (make duplicates), if i would change anything i would have to make changes in all services ... horrible :/
Thanks in advance.
1- Secure them all (the entire application) using one service which
make use of spring security and which will be asked for whenever a
client access one of the services.
This link will help you : https://www.youtube.com/watch?v=3s2lSD50-JI
2- Share some resources which are used by all most services such as
domain model classes.
Here it is about how to organize your project in your IDE or in your architecture. Using packages, shared libraries, shared projects or maven modules can help you.
3- Deploy all services inside one " application container ".
Your IDE or Maven should be able to help you deploy you application in a container. In the case of Spring Boot, there is an embedded Tomcat server that can run your application. Or if you have your Tomcat stand alone installation, you can deploy it by your self.
Reading you post, I guess your are new in Spring Boot development. The learning path I can suggest is the following (in my point of view) :
N-Tier Pattern for application architecture, and the purpose of the layers
The architecture of the Web and HTTP protocol
SOA and REST Services
Maven to build and compile your projects
Spring Boot, in mostly moderns architectures used to implement Backends my exposing REST Services
You can find by Googling tones of well explained documentations and blogs concerning those subjects.
I am trying to build a new application with spring boot microservice framework. I have tried some demo. The existing demo is too simple, doesn't introduce how to call another service from one service. Should still going through http, or should going through RPC? If going RPC, which RPC framework support?
The way of integrating among services depends on numerous factors, like synchronicity/asynchronicity, load that will be generated, etc. The most popular (I guess) way of integration is REST-based one. Because you tagged your question with spring I would recommend using declarative REST client - Feign that is very well described here. You can use message brokers as well, which are also very well abstracted by Spring Cloud Stream - you can read more here. I think that more in depth discussion should be based on your needs.
If another micro-services are exposing the REST API , then you can simple use jersey client
or httpclient to call them.
I am using ActiveMQ to connect a number of application modules written in Java.
I eventually would have a web interface for the application, developed in either Grails, Struts2, or Rails.
My 2 main concerns are:
to have an external security module that is not bound to the Web Framework in use.
to have an independent security db
Any recommendations for this Architecture?
You should place all your components within a secured firewall. Then you wouldn't need to worry about any kind of security for ActiveMQ. If not a firewall, you should have a way to whitelist your components so only you can connect to them.
For the database, I recommend having one user that read data and one user that writes data. Separating this permissions will be a closer step to someone deleting you data.
You need to secure both parts of your application. For the first part go with Amir Raminfar's answer, and insure that your running on secure servers. Also make sure to use what ever security features are built into MQ to allow the components to communicate securely. For Web Security there is no good way I know of to have a framework agnostic security setup. An option for you may be Spring Security You should be able to integrate it with Struts and there is a Grails Plugin This should make it easier to do security in a relatively common way whether you use Struts or Grails but you will probably not be able to easily use Spring Security from Ruby.