microservice-architecture | Microservice Architecture Pattern using Spring | Microservice library
kandi X-RAY | microservice-architecture Summary
kandi X-RAY | microservice-architecture Summary
All micro services are spring boot applications with dependencies managed by maven. Each Service has bootstrap.yml file which stores minimum required configuration for each service. I have added all above mentioned micro services into one parent project just to make it easy to manage in one place as it is just a POC project, without much business logic abd heavy requirements. You can still run each micro service independently. This is Config First Bootstrap, so you should run Config Server first and Eureka Server second then Api Gateway and other micro services. You may see runtime exceptions thrown by Config Server when you run it until Eureka Server runs and Config server register itself.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Main application
- Entry point for the application
- Starts the eureka application
microservice-architecture Key Features
microservice-architecture Examples and Code Snippets
Community Discussions
Trending Discussions on microservice-architecture
QUESTION
As an example, let's say that I'm building a simple social network. I currently have two services:
Identity
, managing the users, their personal data (e-mail, password hashes, etc.) and their public profiles (username) and authenticationSocial
, managing the users' posts, their friends and their feed
The Identity
service can give the public profile of an user using its API at /api/users/{id}
:
ANSWER
Answered 2021-May-10 at 18:01In general, I strongly favor state replication via events in durable log-structured storage over services making synchronous (in the logical sense, even if executed in a non-blocking fashion) queries.
Note that all systems are, at a sufficiently high level, eventually consistent: because we don't stop the world to allow an update to a service to happen, there's always a delay from update to visibility elsewhere (including in a user's mind).
In general, if you lose your datastores, things get ruined. However, logs of immutable events give you active-passive replication for nearly free (you have a consumer of that log which replicates events to another datacenter): in a disaster you can make the passive side active.
If you need more events than you are already publishing, you just add a log. You can seed the log with a backfilled dump of synthesized events from the state before the log existed (e.g. dump out all the current ProfilePicture
s).
When you think of your event bus as a replicated log (e.g. by implementing it using Kafka), consumption of an event doesn't prevent arbitrarily many other consumers from coming along later (it's just incrementing your read-position in the log). So that allows for other consumers to come along and consume the log for doing their own remix. One of those consumers could be simply replicating the log to another datacenter (enabling that active-passive).
Note that once you allow services to maintain their own views of the important bits of data from other services, you are in practice doing Command Query Responsibility Segregation (CQRS); it's thus a good idea to familiarize yourself with CQRS patterns.
QUESTION
when I'm trying to save roles in the database, the "springit.role table doesn't exist" occur.
I'm not creating a table with name "role" in my database because the teacher in the course which I'm learning now didn't create one.
The exception shown when I call the "addUsersAndRoles()" in the DatabaseLoader class method
So, what is the problem?
Role.java
...ANSWER
Answered 2021-Feb-08 at 06:31For sure you are going to need that table, either created by yourself or by Hibernate.
There is a config which you can add to spring boot apps using JPA in order to automatically generate the database schema (or the parts that are missing). Take a look here https://docs.spring.io/spring-boot/docs/1.1.0.M1/reference/html/howto-database-initialization.html
QUESTION
I know the concept of OAuth2 and OpenID. in our application authentication is happening through OKTA and we receive access-token in a response.
Our architecture is a microservice-architecture and we are using EmberJS
at frontend.
we have to implement remember-me
functionality it will keep the user logged in for the next 30 days.
I did some study on it and came to points that will satisfy my requirements.
- keep user session active for 30 days in OKTA.
- refresh access token periodically based on its expiry time.
How this refreshing will work if browser is closed? Let's say a user is logged in and closed the browser then reopened it after 3 days.
...ANSWER
Answered 2019-Sep-11 at 08:02With respective to OAuth 2.0 best practices, it is recommended to have short lived access tokens. There is a dedicated RFC definition such best practices which is identified by RFC6819 - OAuth 2.0 Threat Model and Security Considerations. There are several sections which emphasise on using short lived access tokens .For example here you can see why it is recommended.
With this perspective, you may handle this situation using browser cookies. Cookies are the mechanism which helps browser and server to maintain states. In a typical web application, login state can be maintained through cookies. There are two variants of cookies.
- Session cookie
- Persisted cookie
The second cookie type, persisted cookies do not go out of browser when browser is closed. Of course user can clear cookies to remove them. In your scenario, you can set such a cookie to user with desired lifetime. In the backend, you need to map cookie value to a state, which should start when backend receive a valid access token/ ID Token (after authentication and authorization step).
About cookies security, there are many things you must concentrate on. But the most important are setting cookie to be secure and HttpOnly.
Also, you may store a reference to refresh token in backend correlating to the cookie. Then for each fresh usage you can use refresh token to obtain access token if you require for example API access with access token.
QUESTION
So I started reading some things about different software architectures and inevitably came across Microservices Architecture. Yet, I am wondering about the way these achitectures differ from each other. In a monolythical approach I would e.g. modify a POM.XML
to take my different layers and pack them into one application to deploy it. I'd say this might even be the most common way to set up a simple application.
Now as I understood Microservices, you seperate each service from each other and let them run independently. For me that means, that every service is deployed on its own (so you basically got a tomcat
running with quite a lot of .war
-files on it. But I think I miss the difference to a monolythical application.
I am going to try to set an (quite common) example:
You got a frontend (e.g. Angular
) with a Spring-Boot
Backend communicating via REST
-Services. Now I take a POM.XML
and do the following steps:
- build the Frontend-Application
- include the necessary JS-files into my Spring-Application
- create
WAR
-file from the project
As a result I got one single WAR
-file that I can deploy but got two Services included: Backend and Frontend. Yet, I would call it a monolythical approach.
Now when I would include the Angular
-Application into my tomcat and deploy a WAR
-file of my Spring-Boot
part of the application (without integrated frontend). That way I would have two deployed services running on the same server interacting with each other that can be replaced without touching each other. By definition I would not call it a monolythical approach (same code, different deployment) but a Microservice-architecture, right? But this can not be the case since literally every article I read told me the same advantages and disadvantages for architectures and I cannot see any difference except for the possibility to exchange frontend and backend (which I have in both cases, yet in one I would need to redeploy the full application in the first case).
ANSWER
Answered 2018-Dec-01 at 13:16Microservices are set just set of guide lines that talk about how to design your application so that it is scalable, manageable and adapts to fast development pace. It is not just about how you are deploying your application.
Over the years, we have learned that when you try build one big application as monolith, initially it gives you pace, different modules in your monolith has complete visibility of each other and can access things, tweak things around as they wish, even one change that should affect one module may migrate into other classes, where it should not have been. While it helps you prototype, but code becomes less and less maintainable. You can ofcourse put in effort to make sure your code remains clean, but that effort grows as app grows.
Also you as developer are required to know whole product and it is difficult to work in silo, without worrying about the whole architecture, which makes it difficult for new people to join and make changes.
Next when you deploy, specially now a day, scale is important, and you need to adapt to traffic. All your modules will not expect high traffic 24/7. But if you have monolith, even if one module is being used by 100 of users your application have to scale for 100 of users.
Microservices just pulls in info from this, and defines some guidelines
You should breakdown your app based on biz domains. Every service is responsible for one aspect only. They talk to other via contract (API or events) and as long as contract stands you can do what you want within your service. New dev need to learn just one service to start with.
Scaling becomes easy, because if you have load on one service only that will scale. Other modules deployed independently can scale as the load specific to them.
By keeping it small you can build fast, make changes in rapid way. No shared database make sure that you take a call on what you want to save, how you want to save and how you want to change.
For you case, just deploy it the way you think its best. But if you start to grow, you have some 50 odd services (or that size project) you will see benefits of divide and conquer.
QUESTION
I have been testing out microservices lately using springboot to create microservice projects. The more i understand about the setup the more questions i am confronted with.
- How are all the microservices that are running, managed? How do developers manage, deploy or update microservices via a central location?
- When deploying multiple instances of a microservice, do you leave the port to be decided during runtime, or should it be predefined?
I am sure there will be much more questions popping up later. Links used:
- http://www.springboottutorial.com/creating-microservices-with-spring-boot-part-1-getting-started
- https://fernandoabcampos.wordpress.com/2016/02/04/microservice-architecture-step-by-step-tutorial/
Thanks in advance.
...ANSWER
Answered 2018-Aug-18 at 19:19you can start with the following:
Monitoring :
QUESTION
Are Logic Apps considered microservices? If so, is making HTTP API calls from Logic Apps, whether it's using HTTP/Function/APIM connectors, not a violation of direct HTTP communication between microservices?
...If possible, never depend on synchronous communication (request/response) between multiple microservices, not even for queries. The goal of each microservice is to be autonomous and available to the client consumer, even if the other services that are part of the end-to-end application are down or unhealthy. If you think you need to make a call from one microservice to other microservices (like performing an HTTP request for a data query) in order to be able to provide a response to a client application, you have an architecture that will not be resilient when some microservices fail.
Moreover, having HTTP dependencies between microservices, like when creating long request/response cycles with HTTP request chains, as shown in the first part of the Figure 4-15, not only makes your microservices not autonomous but also their performance is impacted as soon as one of the services in that chain is not performing well.
ANSWER
Answered 2018-Feb-17 at 12:57Yes, Logic Apps are primarily Http based services. Whether or not it's 'micro' really doesn't matter because 'micro' is too abstract to have any real meaning. It was a useful marketing term at one point but it's tour on the tech fashion runway has ended. So, don't even think about that. ;)
What the authors are trying to express is that you should avoid chaining dependencies in an app's architecture. A waits for B which waits for C which waits for D which waits for E, etc... That's the first line in the graphic.
Instead, Basket can check Catalog on it's own, then call Ordering, while Inventory is checked in the background. You only one level deep instead of 4.
QUESTION
I asked a question in: Microservice Architecture dependency which pattern to use when using a clustered Microservice architecure.
I recieved answer that point to point should work but when reading: https://nats.io/documentation/concepts/nats-req-rep/ It feels like all subscribers recieves event (and because of that handles it) but there will just be one subscriber that responses. This will not work when putting an order event that will trigger an update-inventory-event that Inventory microservices subscribes to (as in example in link) i.e it wont work in a clustered env due to inventory will be updated the same amount of times as the amount of microservice instances.
How can I solve this scenario using Nats?
Thanks in advance!
...ANSWER
Answered 2017-Jun-12 at 16:13NATS.io supports this feature using queue groups:
All subscriptions with the same queue name will form a queue group. Each message will be delivered to only one subscriber per queue group, using queuing semantics. You can have as many queue groups as you wish. Normal subscribers will continue to work as expected.
Connect your services using the queue group (sample is node.js):
QUESTION
I've started the journey of learning more about this architecture using Spring Cloud and the Netflix's projects.
From a general standpoint, I do understand the architecture but now that I'm actually coding an app, a horizon of doubts has appeared about some minimal stuff that could have a big impact in the big approach of this architecture.
First, my app is based on this tutorial which I assume as valid since it's from Spring itself: https://spring.io/blog/2015/07/14/microservices-with-spring
And now, the problem: (ALL THIS USES EUREKA) let's say I've a microservice "accounts" which consist only in Spring Data REST for the persistence/HATEOAS and on top of that I've a client service which consumes those endpoints using RestTemplate (because I'm using Ribbon's load balancer). From my view, this is how it works: user -> frontend -> client service -> Spring Data REST endpoints (the microservice) -> DB.
This is nice and all but when I get the endpoint response (from the RestTemplate), it contains hypermedia going directly to the microservice, and per se, you now can drive your way through the microservice while ignoring the load balancer, which, for me, kills the purpose of it. And if I've like 5 microservices scaling to each other, it means the user is now focusing into just one of a broad way of 5 microservice that are supposedly managed by load balancer.
Q1: Is ok for an user to have that knowledge of the API (and then kinda killing part of the structure)?
Even if I add the links to the services detected by Eureka and delete the current endpoints to that microservice, those links aren't going to work and such means I'm chopping of the hypermedia links.
Q2: Is there another approach to this? Through some kind of proxy, external load balancer, dns or something like that?
P.D: I don't know if I'm being clear enough. Please let me know if something is misty.
P.D.2: Summary question: what to do with those media links? Let them be or use something else (please tell) to actually get them "right"?
Edit: Based on the advices below, I added Zuul which seems to be the solution to my problem. Now, about Zuul, where should I use to filter?
My app is like this right now: account-microservice (Spring Data REST) and account-web-service (client with the RestTemplate Load balancer). Those are the Eureka registered names.
Where must go the @EnabledZuulProxy? Inside the microservice or inside the client?
My current config is this one (currently, the @EnabledZuulProxy is in the client):
My microservice:
...ANSWER
Answered 2017-Feb-24 at 16:28If you use Zuul from Spring Cloud Netflix as your load balancer it will automatically add the X-Forwarded-Host
header which Spring HATEOAS will respect. When that header is present HATEOAS will generate links using the host value in the header. If you are not using Zuul than you will have to configure your load balancer to add that header.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install microservice-architecture
You can use microservice-architecture like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the microservice-architecture component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page