Microservices tutorial with Spring boot 3 | Full course
HTML-код
- Опубликовано: 18 июн 2024
- #microservices #microservicestutorial #springframework #springboot #aliboucoding #alibou #springboot_3
🎁 Spring Data JPA course: aliboucoding.com/p/the-full-g...
🎁 🚀 COUPON Code: EARLYBIRD20
Discover the power of microservices architecture in this in-depth course, designed to provide you with a thorough understanding of building, deploying, and scaling modern applications. Through a blend of theory and practical examples, you'll explore essential concepts such as API Gateway, Config Server, Discovery Server, and hands-on implementation of two real-world microservices, Student and School.
Throughout this extensive course, you'll:
Understand the fundamentals of microservices architecture and its advantages over monolithic applications.
Implement an API Gateway to centralize and manage requests, providing a single entry point for your microservices ecosystem.
Utilize a Config Server to enable centralized configuration management, simplifying application maintenance and consistency across environments.
Leverage a Discovery Server for efficient service registration and discovery, ensuring seamless service-to-service communication.
Develop two practical microservices, Student and School, to understand the nuances of designing and building modular services.
Explore communication between microservices using OpenFeign, an easy-to-use, declarative REST client.
Enhance application observability and debugging with distributed tracing using Zipkin, allowing you to visualize and troubleshoot latency issues.
Learn best practices for securing, monitoring, and deploying microservices in production environments.
By the end of this comprehensive course, you'll have mastered essential microservices concepts, techniques, and tools, empowering you to create and deploy sophisticated, distributed applications with increased efficiency and confidence. Whether you're a developer, architect, or DevOps engineer, this course will equip you with the skills to successfully navigate and thrive in the world of microservices.
👉🏻 Source code: github.com/ali-bouali/springb...
Don't Forget to
===========================================
💯 Free courses here: aliboucoding.com/courses
💯 Subscribe to the youtube channel
💯 Join our Discord Community - / discord
💯 Join our Facebook Group - / 589612651142975
💯 Join our Instagram: / alibou_coding
Table of content
00:00 Intro
02:15 Microservices architecture
05:40 Prepare the monorepo workspace
06:41 Create the API Gateway micro service
09:52 Create the Discovery (Eureka) service
06:41 Create the API Gateway micro service
10:57 Create the Config server
11:32 Configure the discovery server
16:10 Create and implement the Student micro service
27:48 Create and implement the School micro service
34:49 Establish an HHTP communication between the two micro services
49:38 Configure and test the API Gateway
55:25 Distribute the configuration
01:02:14 Distribute the tracings to Zipkin
Join the Micro Services course waiting list and get and get an exclusive *EARLY-BIRD discount*
aliboucoding.ck.page/d0f9317e13
Many many thanks for your demo project!! I could run your project on my machine perfectly. Very high quality!
Any time!
Thank you so much, Man!! You deserve lots of appreciation.
Glad I could help!
Thank you for this wonderful video, very precise, understandable and straight to the point
hey, bro.. the stuff about config server worked for you?
like before watching .. thi9a fel mantouj ya3tek saha bro
I really appreciate that bro
The best guide, which I have ever seen, thx you a lot, really good job!
Glad you liked it!
It was incredible, thank you so much!!
Glad you liked it!
I have followed this tutorial successfully. It's a such helpful resource. Keep making more and more.
Thank you, I will
It's insane how good you explained this difficult topic
Glad you think so!
Thank so much! It's amazing!
I'm glad you like it
What an Amazing Course this was! Had few errors along the way but managed to fixed them. Your teaching style is incredible. Thanks a lot
Great to hear!
Thanks for this video!
the gateway applica.yaml part i modified, as of today (20th Jan 2024) when i built this project,
instead of
spring.cloud.gateway.routes i did spring.cloud.gateway.mvc.routes
i dont the exact reason but i think the first one requires spring web flux (reactive) and later one is based on our synchronous spring web
Feel free to correct me if im wrong.
Amazing job as usual !! bravo Ali Hopefully there is a second part with Async Communication or monitoring prometheus grafana etc...
Good idea, will schedule it
@@BoualiAli Thank you kind sir, plus Keycloak in microservices, right? :)
Felicitation pour ce bon travail et Merci beaucoup vraiment Java 17 et Spring Boot 3❤
Avec plaisir :D
You're awesome! I sincerely thank you for making such great contents.
Glad you like them!
Awesome tutorial, thanks for your time and dedication
Glad you like it!
great work! thank you!
Glad you liked it!
Nice tutorial. I don't really understand the process of creating/setting up postgresql with docker. Is there a separate docker container for both the student and school service?
All was great up until 31:02. I needed to get postgresql set up in docker for the student/school to start up. Great introduction to microservices. You've got a sub. Much appreciated.
Great to hear!
Can you tell me the process ? I'm stuck there as well can't figure it out tried various things.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure (error)
Great content as always ❤... thank you
Happy you liked it
thank you for the amazing content!
Happy you liked it
Thanks for this amazing course
Happy you liked it
Excellent course thanks!
Happy you liked it!
Cool, I really like the way you set it up. Recently I bought some old-school microservices course on udemy, but well.. Yeah, it's outdated and I didn't process with the course. 😅
Glad it was helpful!
thank you , you make the best videos on youtube
Wow, thank you!
It's awesome! thanks a lot
Happy you liked it!
Thank you for sharing 😀
My pleasure 😊
Maasha Allah, this will be super super awesome, especially from your Ali 😁
I didn't finish watching it yet, and I'm very sure if I watched it I'll come to make another comment in Sha Allah ❤❤❤
Thanks once again Ali. JazaakAllahu khairan and also Eid Mabruk 🎉
JZK brother.
I'm really happy that you like my content.
Aid Mabruk
thanks a lot for this tutorial !
Happy you liked it!
Thank you!!
my pleasure
I don't have much words to say. But Simply Many Thanks for this great tutorial.
Happy you liked it
Amazing video Sir. This is my first video that I am able to follow till the end and code along with you. This video answered all my questions on Spring Boot and Microservices. Now I understood how the microservices communication happens through API Gateway. Thank you so much for detailed explanation. As I am novice to Docker and Zipkin, couldn't complete this part.
I am glad to inform you that I have successfully created and executed the project. This video is very helpful to understand the concepts Sir. Thank you so much.
Glad you liked it!
I just went on RUclips to start learning a Spring Boot microservice tutorial, and boom. There are no coincidences. :D
Happy you like my content.
Nice to have you herer
Thank you very much for wonderful Spring Boot Microservices Tutorial. Please do video for all Microservices restapi security
Really happy you liked it
Sure will do it soon
This is my first video that i have never skipped listening till the end. it really opened my eyes about how to configure my upcoming personal project. One missing bit in this Video is you could have implemented the authentication and authorization. so that it will be a full PROD ready application. any way will catch up from your upcoming videos. thanks for this wonderful vlog.
Happy you liked it.
I will create a video for security
@@BoualiAli hope the soon
@@BoualiAli we will really appreciate a video on authorization and authentication on microservices
Thanks
Welcome
Thnks for this
Welcome 😊
Thank you so much
You're most welcome
well explained thank you
Happy you liked it!
great job as usual , shine brother
thank you so much brother
Amazing tutorial, brother.
Glad you liked it
Amazing job. It's very easy to understand and implement. I hope you create a microservice with security course including either the JWT or OAuth 2
Happy you liked it
I will provide one about security too
@@BoualiAli Awesome. I Can't wait
Can you show how to add authorization in the microservice? I know you have a lot of security videos, but I thought the last microservice authorization video would be very helpful and we will see the full microservice application :D
I'm working on covering a lot of topics in micro services.
Stay tuned!
thank you
My pleasure
Thanks Ali, nice job . Can you make version of the course with replacing of Spring config server with Kubernetes config maps and secrets instead ?
Sure, will do
great job congrats for this amzing work ur doing great i hope u do async Communication instead of http or mybe Grpc and if possible could u cover more of spring cloud and agian amzing presentation and information
Thank you for the feedback. I will do an asynch communication video ASAP
Thank you so much I have implemented it all slightly differently as to work for my use case but overall the same and these have been great tutorials and great explanations I do have a question though we do this to enable load balancing but how would that work for your applications as the server port is into the config server so if u opened up another application it would still redirect to the first one?
An orchestrator like Kubernetes should take care of this
Your video was wonderful sir,
but i have a question: how can you use spring security and jwt in this project with login register sir
awesome
Happy you liked it!
Awesome video!
Learning alot from you.
But i have a question, how to implemente the security for the microservices arch?
the authentication be in the gatheway or the gateway should request the auth from a service that can handle it?
I will make a video about that
Thank you Ali for this video. It is interesting.
With this solution, every time we need to add a new microservice we need to change/deploy the gateway.
How can we add a new microservice without changing/deploying the gateway?
You don't need to re-deploy the gateway every time.
Externalise the config to config server and the gateay will reload the config from there.
That's why I added the config server patter
Thus great lessons...You're helping many across the world....Ali, how do to host spring boot MicroServices on a Live-Server-Hosting
Great suggestion!
I will add this to my schedule
@@BoualiAli thank you Ali...We're very grateful
I thought with the help of Eureka I wouldn't have to remember which port the microservices are on, I didn't understand why you need it.
Great work Ali! Nowadays, what do you think is best for service discovery? Spring Cloud Netflix Eureka or Kubernetes? Thanks for all!
Depends on your infrastructure and your technical choices
Good job about video but can you make further one video about using message queue as kafka or rabbitmq with microservice. Thank you
Yes, soon
Hey Bouali,
Can you please create a detailed session on Micrometer and observability in spring boot 3 and how to connect our microservices to graphana to observer our microservices.
Great suggestion.
I will create a video for distributed monitoring using the ELK stack.
Let me know if this is what you’re looking for
@@BoualiAli yes using elk we can centralize logs only but using graphana we can monitor all microservices so pls make a detailed session on new observability api in spring boot 3 lot's of developers are looking for this
thanks for this awesome video, its a lil late but Eid mubarak, can you please tell me what tool have you used to design the architecture?
Eid mubarak.
Draw.io
Thank you for the knowledge and skills you're sharing on your channel. Your videos have been incredibly informative and inspiring, and I've learned so much from watching them.
I am having trouble externalizing the configuration of my discovery service, and I've encountered the same error you had precisely at 1:00:51. I'm unsure how to resolve this issue, and I would appreciate any advice or guidance you can provide.
Thanks again
Really happy you liked it
Can you give more details about the issue?
tengo el mismo problema ahora nada funciona
What are the advantages and disadvantages of using bootstrap yml to set up Spring Cloud? Why don't you use bootstrap yml approach?
bootstrap.yml is deprecated
Thank you brother 😀and please keep uploading videos like this, what about the front end?
Thank you brother.
I'm creating the plan for an Angular course soon
@@BoualiAli Angular course for me is very important at this moment. Please Ali
@@tomaszgrabowski8312 ASAP
Thank you @Bouali. But i couldn't add the OpenFeign client to my project. Maven doesn't seem to import the dependency. What do i do?
I will check the latest versions
Excellent! But where should authentication and authorization be implemented with spring security?
I have seen your videos, but I don't know how to implement them in that microservices architecture.
API GW
thanks for the video, I wish you could answer me this question, is it not necessary to register the gateway and config server in eureka?
Not really necessary
Hello guys, if someone has an ERROR when obtaining students by school ID, make sure when declaring the StudentClient variable in the SchoolService file, it has to be final.
Salut Mr Ali et merci pour ces formations très importantes pour nous jeunes étudiants. Ceci dit, j'ai une question, est-ce que avec cette approche, nous pouvons toujours avoir dans le dossier config, un fichier application.(properties | yml) qui permet de centraliser toutes les propriétés communes à des microservices ?
Oui tout a fait
Thank you for your video, but I have a question concerning Git when using microservices. What's the best practice: to put each microservice in a separate repository or all in one, especially if we are using different frameworks, such as Spring Boot and Node.js, and we have a frontend app? ps:its a group work
I prefer working with mono repo since I want to have all the code in one place.
Many companies are migrating to monorepo now
monorepo.tools/
Nice ❤. Just one thing you did not show that the 2 services of students and school are no longer available on their respective ports .or does they still exposed to public??
I mean how does the usage of gateway api hide those 2 services from being exposed to public . Please explain that point.
API GW is the entry point.
Hiding the services should be done when deploying and configuring your network (VPC / Cloud / Container, ...)
Hi I have a question, I know that for sake of efficiency your are keeping the practices light. But should in the architecture given the Databases being two separate entities with different containers ? *IE every microservice to have its separeate independent posgres database ? Thank you
Yes totally true
Very interesting video. However, I wonder if I just missed some steps about postsgresql. my student and school application won't start until I installed it and created the students and schools database manually and also set a password for the postgres default account. After both were running and tried to use postman to post the school entry, I got the following error, "ids for this class must be manually assigned before calling save():". I'm thinking that maybe I have to manually create the table first?
What you did is what needs to be done as a first step.
I assumed that everyone is capable of setting up his own working environment and have things up and running before starting.
I will consider your input for future video and at least mention what needs to be prepared (pre-requisites) before tackling the course
How would we go about implementing authentication micro service? As in diagram wise so I would want every request to go though it but some could be authorised though JWT token
Implement it on the gateway
Amazing video, let me ask you something. How zipkin works? you just put dependencies into pom.xml and automatically tracing was sent to zipkin? I mean, you didn't need to put zipkin's url into application.yaml or something like that to connect the microservices to zipkin server.. Thanks a lot.
It works with the default configuration coming from the starter. You can of course override the default config. Please refer to the documentation for more info
How to implement a rollback in the microservice in the event that one of the services fails. What should be done about failed transactions that affect every microservice? Would you kindly provide advice or a video on how to handle rollbacks for each microservice's transaction?
Use SAGA pattern
Nice, can you add load balancer, messaging like kafka and also caching with redis
Nice and relevant suggestions.
I will try to cover that asap
Subscribe to my website and you will receive many updates.
aliboucoding.com/courses
Isn’t it better to communicate between microservices via Eureka hostnames instead of making requests from internal network to the API gateway?
Valid point
Hello Mr. Ali i did not watch the entire video yet but i just want to ask a question. In microservices architecture how we can implement api gateway to security?
Just apply the jwt security video to you api gateway
❤👍
السلام عليكم
اولا شكرا على الشرح الرائع ربنا يجعلها في ميزان حسناتك
عندي سؤال بخصوص الحماية في الميكروسارفيس
لقد رأيت الشرح الخاص ب jwt في قناتك
اريد اضافة jwt في microService
هل في كل ميكروسارفيس نضيف حماية
ام في gatewaye فقط ؟
و شكرا
you can only add it to the gateway. But it is also recommended that each microservice needs to check and validate the token
Can there be a discount for the country of Argentina about your courses? . Because in our country is undervalue our money.
please contact me via e-mail: contact@aliboucoding.com
Assalaamu alaikum bro Ali. Thank you for all your video series which are only beneficial for us. I, as a self-learner, find your channel to be one the most useful ones to learn programming.
However, I noticed something unusual about this microservices lesson. You are accessing api/v1/student/** endpoint both through its own port which is at 8090 and through gateway which is at 8222. I think all microservices, including student microservice, must be accessible only through gateway, when requested to other ports, 8090 or 8070 for instance, "path not found" response must be returned. And also, on Eureka server at localhost:8761, gateway did not appear as a running server like STUDENTS or SCHOOLS.
Can you, please, make any suggestion to configure my microservice architechture so that it is only accessible though gateway? Thank you again.
All the microservices are configure to call the API Gateway url not the service it self.
CHeck the code (config-server)
بارك الله فيك
Excusez moi ,j'ai une question dans le cas d'une API Gateway, faut-il créer un filtre personnalisé pour appliquer autorisation sur les micro services ou existe-t-il une autre méthode à privilégier
Tu parle de la sécurité?
Je suis actuellement en train de chercher des informations sur le fonctionnement de la sécurité RBAC avec une API Gateway et j'aimerais approfondir mes connaissances sur ce sujet. Plus précisément, j'aimerais comprendre comment une API Gateway peut recevoir un token, le filtrer pour récupérer les rôles et diriger les requêtes en conséquence. Malheureusement, je constate qu'il y a peu de ressources disponibles sur ce sujet, la plupart étant axées sur l'utilisation de Keycloak et d'Oauth2, ce qui complique ma compréhension. Auriez-vous des suggestions de lectures ou des informations à me fournir à ce sujet ? Je vous remercie par avance pour votre aide.
Amazing video.
Thank you
mans looking directly in my soul
Happy to help.
Hey! Great Sage, please, I found out that on the video you did not show few things. Hence applications fail for some of us without extensive knowledge.
1. On the Entities in both School & Student Micro-services. Your video didn't show that you added "GeneratedValue" on the Id
2. On the school service when you injected the student client "private final StudentClient client;", your video didn't show when you added the "final keyword" in order to enforce the injection.
Thank you so much for wonderful lectures. I will be signing up for your courses because you are quite skilled in impacting knowledge.
I need to recheck the video. But I supposed that the viewer is familiar with Spring boot.
If it is not the case, please watch the Spring boot for beginners video in my channel and you will have a better and clear understanding how the framework works and then this video will be like a piece of cake for you.
Happy to have you here!
@@BoualiAli are the courses on your website on time-bound access or lifetime access?
Regards.
@@IamKanuKingsley yes lifetime access
Can you please push the latest changes to the git repo that you put in the description
Sure,
I will release a new microservices video soon
@@BoualiAli Thank you, I'll turn on the notifications bell for that
@@BoualiAli If you could use rabitmq or something similar and explain the pros and cons of using it
With circuit breaker, please
coming soon
why u use .yml instead of .properties ?
Easy to read
There was no way to operate the externalization in config-server
What is the problem?
@@BoualiAli
several days passed and avoid using the config server to be able to continue with the project since everything worked well without it but I think the error was something about
2023-09-05T02:26:29.731-03:00 INFO 5932 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2023-09-05T02:26:29.957-03:00 INFO 5932 --- [ main] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='localhost:8761/eureka/}, exception=I/O error on GET request for "localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: no further information
Hello👋hope you are doing good, I am kindly requesting a tutorial on microservices that includes security.
This includes securing api-gateway. secure service to service communication, access control, Creating custom filters: Use custom filters to add additional security measures to microservices. Filters used to perform tasks such as logging, auditing, and rate limiting.
Spring Cloud Config: Use Spring Cloud Config to store the security configuration for each microservice in a centralized location to easily to manage and update the security configuration for all microservices.
Spring Cloud Vault: Use Spring Cloud Vault to store sensitive security information, such as passwords and keys, securely. To ensures that sensitive information is not stored in plain text in configuration files.
Great suggestion
Thank you
You cut the moment, whith adding final to studentClient.
sorry for that
yml programming....
?
COUPON Code: *EARLYBIRD20* => Spring Data J PA course: aliboucoding.com/p/the-full-guide-to-master-spring-boot-data-jpa
why not use http interface?
I will use in a coming video
The configs for gateway didn't work for me.
what is the problem
@@BoualiAli I don't remeber the error I encountered or why did I got it. It's possible that I've made a mistake. Either way I learned a lot and I thank you.
ali boo
Thank you
bon cour mais on veut pour le français
Merci, comme j'ai deja mentionne, le nouveau cours sera en Anglais mais je vais essayer d'ajouter des sous titres en francais
How do you sound like the same as amigoscode 😟😟
The spring security video on amigoscode channel is mine and I accepted that publishes it on his youtube channel.
Also if you watched the introduction (which I really don’t think so) he mentioned that the video is brought to you by Alibou and he mentioned my youtube channel also.
Also, you see my face and hear my voice on my videos so I guess you can relate that the video is mine and not amigoscode.
Thank you for understanding
ruclips.net/user/clipUgkxGQnio8fOuFYx8AT2URuL9efPjk2Kghe5
vous nous avez abandonner nous les francophones ?
Non pas du tout mon frere. Mais comme la communaute a grandit et plus de monde de partout demandent du contenu, je dois fournir du contenu en anglais (international)
Mais j'ajouterai des sous titres en francais pour les prochaines videos
@@BoualiAli Oh, je comprend, mais avec les bases qu'on a c facie aussi de s'en sortir
Your videos are good but this especially you are not tidy and you do not get to understand well for those who are starting with microservices like me
What do you mean by : not tidy?
Did you expect something more basic than that? If yes what were your expectations?
@@BoualiAli Your videos are great but in this one especially, I felt like you were going a little fast.
Equally today I will see it again and I will understand it better sure. Thank you for the free quality content you offer , a hug!
Hi sir, i get a nullPointerException even though i add @EnableFeignClients in 47:32
can you provide more details?
@@BoualiAli i fixed, thank you :)
how you fix it? got the same error
even if i add the @EnableFeignClients, still getting NUllpointer
in SchoolService class add class menber private final StudentClient studentClient; (he added final keyword offscreen) without final, spring boot won't autowire
You are calling the services, even in the gateway, by passing localhost:port, wouldn't make sense to use the actual service name registered on Eureka?
gateway:
routes:
- id: schools
uri: lb://FIRST-SERVICE-NAME
predicates:
- Path=/schools/**
- id: students
uri: lb://SECOND-SERVICE-NAME
predicates:
- Path=/students/**
I didn't get you question. Sorry
Can you explain a bit more?
@@BoualiAli
In your gateway.yml you are doing:
routes:
- id: students
uri: localhost:8090
predicates:
- Path=/api/v1/students/**
- id: schools
uri: localhost:8070
predicates:
- Path=/api/v1/schools/**
where uri: localhost:8090 and uri: localhost:8070 will be poiting to a specific instance of these applications or a loadbalancer/vip. but since you are using eureka, you should take advantage of this service discovery and use it. it would be something like:
spring:
cloud:
gateway:
routes:
- id: students
uri: lb://STUDENTS-SERVICE
predicates:
- Path=/api/v1/students/**
- id: schools
uri: lb://SCHOOLS-SERVICE
predicates:
- Path=/api/v1/schools/**
where lb:// will have the services name that are discovered when querying eureka. so you won't have to care about which application is in which environment/vip/host etc.. it gets automatically resolved by gateway + eureka registered services
@@BoualiAli i think, he mean that: your gateway routes is not use the reference from eureka (discovery service), you use the hard uri (example: localhost:8070)