End to End Microservices with Eclipse MicroProfile - Ivar Grimstad (Jfokus Brown Bag series)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi and welcome to the third edition of jay focus brown bag today we have a presentation for about microservices and i would like to introduce today's speaker eva grimstad welcome and please introduce yourself thank you very much my name is ivar grimstad i work for the eclipse foundation i'm located in uh malmo in sweden so and to prove it i have this this cop here so for those who are swedish you can read this right so you know that that is a very uh scania word so i'll share my screen here and let's get started so okay so this talk is end-to-end portable microservices with eclipse micro profile i'll do a lot of coding so there will be a couple of slides just to accompany it but most of it will be live coding and as you probably know the microprofile working group has been established now and i think it's tomorrow the vote ends where they convert the microprofile projects over to be a specification project and that means they can get rid of the eclipse name in front of microprofile so from tomorrow of this presentation will be called end-to-end portable microservices with microprofile so so this is the last edition of the eclipse microprofile okay as i said my name is ivar grimstad this is my twitter my github my linkedin please feel free to contact me i'm active in a bunch of open source organizations as you can see on the bottom here and also run the uh java forum java giger and manner this talk is about microprofile and just to give a very short introduction to what microprofile is uh it is as as the slogan says optimizing enterprise java and and making it easier to create microservices on the java enterprise platform and it builds on top of four specifications from java enterprise or java ee and that is cdi for having dependency injections and context and gluing everything together you have the json specifications json p and json b for processing and binding json objects back and forth to java and then you have the jax rs which is the specification for creating restful endpoints and on top of these you have eight uh microprofile specifications that uh tackle different problems you encounter when creating microservices and and uh very quickly open tracing is for tracing facility across services you have open api for documentation rest client for calling clients in a typesafe way config for externalized configuration fault tolerance for circuit breakers uh bulkheads etc to make your uh services uh reliable we have metrics to measure services for example with prometheus or similar and json web token propagation for security as well as health for uh enabling your services to be able to do to to see if they're up and running or not like in kubernetes you can have these checks for if they're live and ready and i'll demo most of these specifications here today i i don't think i'll have time for or do anything with tracing or or metrics but maybe we'll see but uh most of the others so i think i can fit in in these uh 30 minutes there are lots of implementations here uh with microprofile and in this talk i'll use uh corkus open liberty payara tommy and helidon so i hope we have someone from oracle so we can report back that i did some some hella done stuff because um that's an oracle product and uh the eclipse microprofile or microprofile the the web page you find information about it and and the starting point for everything is microprofil.io and as you see the the current version of microprofile is 3.3 there is a fourido coming out at the end of this year they are as they are working on this uh conversion to specification projects as soon as that is done they will start the release process for getting photo out so there is a new version coming out pretty soon and there are um betas and and nightly builds you can explore the the facilities there already but in this talk i'll use mostly three to three and in one case three or two i think what i'll also will point you to is the microprofile starter and this is the the place to quickly get up and running with a uh microprofile project and uh let's uh do that and and look at how it uh it looks like and what i'll do there is to create this application it will be a greeting service on open liberty and i'm going to use the the microphone starter to do it so let's navigate to the starter and as you see it's start microprofile diode and if i go in here and and i can type type in my group id id and name of the application i'll just use most default here i'll call this some greeting i'll choose version 3-3 and okay i'll just reload the page so i'll use version three to three here and with three two three i have these two to choose from if i choose another version you'll see i have a different set of vendors so in this case i i'll use 3.3 and i'll choose open liberty these are just examples so if you check the boxes here you get example code down but in this case i'll actually uh code the samples myself you can also choose between uh eight or eleven depending on uh what the implementation supports so i'll just use eight there i think i'm using 15 to compile with but uh let's just keep the source level at eight so just extract this one in the jfocus folder there you go and then open the ide and i should be able to let me see here i assume stuff is kind of hiding things i'll open this um and we're gonna put it downloads geofocus greeting so i'm getting the the project in here and uh what i'll do uh just to start off with is to go into my um this folder and i'll just type my maven liberty dev this is the development mode of liberty so so it will uh build my project for me and uh and just start it in development mode so i can do changes uh as we go so the first time you build it it will take some time because it downloads these server artifacts you need i i did that earlier today so it should be here already but the first time i built it here it has to package everything again since uh it's a new project so it takes a little while uh in in later uh runs it will be faster so while it's going there let's go in and look at the code and and you see this is a super simple it just returns hello world so it's uh nothing magic going on here and it's uh in a path hello and uh the application is slash data so let's see if it's coming up i promise you it will be faster next time so there it is up and running so let's go and look at this in the browser at localhost i think it's on 1980 default and it's data hello and it says hello world so there is no magic there so let's go and and uh and uh fix this application and do some stuff look at the different microprofile things for example let's add the um the liveness and readiness tests and i have some templates here so this is the the microprofile health check so here you can see how i'm implanting the health check and i'm using the liveness probe and and the liveness probe is to give kubernetes a a or or whatever environment you're running your application in saying that this application is live so so don't kill it yet it's kind of give the the uh the container infrastructure the the message that um but it's coming up and and then we have the the readiness probe which is um influence also the health check but here we use the the readiness and and this is to to give the infrastructure the uh message that hey i'm ready to receive traffic so so here you can see it it says dukes ready and the other one says duke isn't live so let's look at how this looks in the browser and then i have the health check and if i go there you see i get all of them on the health endpoint if i want to filter on the liveness probe i can i can uh go and and say i only want the alignments prop and it see it says duke alive and as well the readiness will also be at flash already so these are the things you do you configure your environment with to see how easy it is it's just add these classes and you have uh implement the health checks and you can do whatever you want here with the other data and build this structure the way you want another thing that actually comes for free with this is the documentation so the open api in microprofile actually generates all this um this open api configuration here that swagger uses and and liberty actually adds a swag ui on top of it as well so you can actually go in here and and try it out so so so you you get the the swagger documentation everything up and running uh for free so i don't think i actually managed to click the button it was too big for me execute so there it should should go and then and say the uh yeah i don't have the the correct response you say but but i get a a okay here so you don't have to do anything to document your code to get the swagger ui up and running you could of course add some sprinkle some annotations here and there uh to um to uh if you want to document it use swagger annotations or open api annotations there as well so far so good so we have this hello world application up and running but what we really want is in these coveted times uh we don't travel much so this problem is kind of unusual these days but uh if you if you travel a lot to conferences you uh sometimes end up with uh oh i'm going a little bit too fast here let's go back you you sometimes wake up in the hotel room and wonder where you are and what you're doing there and uh this kind of this this application is meant to help you with this so i can configure it when i go to bed at night and when i wake up in the morning i can refresh my browser and see where i'm at and what i'm going to do so if i had run this today it would say you have a microservice talk at jfocus today tuesday at 12. and in order to do this uh we'll split it into different services and we'll have one service uh saying hey it's a uh to tell me where i am so uh i'll generate a service using quarkus that will return the uh at j focus to me let's go into the starter again and this time i'll call it location and i'll use 3.2 to get quarkx available for me and i'll download this one so we have the location service i'll extract it there to in the jfix folder and let's go into our ide again and import this oh there we go so get the location in there you go and i'll just have to cheat a little so where is my location service there it is and the corkis also have this uh maven plugin so i can go to location maven goes dev start it up and what i want to do here is to add some stuff first of all uh i want to fix the port i'm running at so i'm going in here to the property file and let me just see where i have the properties i'll go in there and set it to 8484 and start it up again and this is data and this is hello let's call this one location and uh rather than returning the um the uh we'll actually use microprofile configuration there so we'll inject a config property i call it name equals place and let's give it the default value that is somewhere let's make it a string sorry place and rather than returning hello world we're going to return at and then place i'm sorry press place there we go and semicolon so so then uh i'm injecting a config property here name name value config properties from microprofile config and i've given it a default value so if i run this one it should on localhost 84 oh sorry 8484 data location it should say at somewhere if it's running yeah and it says at somewhere so if i want to configure this one i can give it an environment variable or or i can give it a system property so let's call this one j focus like this so i'm giving it a system value at runtime and this means you can do it differently for for different runtimes environment so when you move to a production environment they give another property or if i move to another hotel room it will be another place that i'm i'm using there so now it should return at jfocus as we want it to do let's go next service and use a conference service and in this time i'll use helidom and here i won't use the starter i'll use another way because the holodon comes with a client tooling called helidon i've pre-installed it here so here we can can can actually build a product uh a service using this client tooling so let's use helidon in it here choose the microprofile version i'm using a bare installation i'm calling it conference yeah it's com example the artifact is the is conference a version that's good packaging.com example conference and i won't start the development group right yet for some reason it it calls it uh beer mp so i'll just move beer mp to conference so there and imported in the ide so we have it there there you go so the conference finish it up so it should be coming in here and uh helidon can be uh run in the hell in in dev mode as well but for that i'll just fix the um the port number and this is using microphone config to do that so i'm going in here and i think i want this one to run on 8282 like this and then i'll start hello don in uh grab my id frozen i don't know there we go so it starts in in development mode and then i'll go and start fixing it up a little let me see if i can find the conference service here so here i only have a a greet resource on greet so i'll call this conference i want to have a conference application class so i have a a [Music] root context of data so it's similar to the others so i'm calling this one conference rest at location and i'm just in like this there we go so it should be why isn't this combining that's weird oh i don't get why why this one won't go yeah let's see if we can do without this i think this is just defaults anyway so let's go over there and uh i'm not sure if this one actually is running or not so let's go and test it it's on localhost uh what did i say uh edi tv2 data conference and it says hello world so it's it's so it's actually sort of working even though the idea doesn't recognize isn't compiling but very good so go let's go and uh and and say that we want to we want to actually call as you see from from the the architecture diagram i want to call the location service to get the app.js string there so let's go and use the microprofile rest uh client and i think i have a template for that that's good i'm going to to call this one so what i'm doing here and this is kind of kind of cool i'm doing a interface and i'm using a lot of jax arrest annotations so so i'm saying this is a get method here i'm using the fault tolerance from microservice and say hey 500 milliseconds that's that's enough otherwise call the the say it method which is returning uh that i have to look at the window to figure out where i am and it's at the conference so so so so here i'm using jax or s annotations on an interface and i'm using this res register rest client and register rest client headers to to register it with the runtime that i'm generating in proxy to the client what i also have to do is to configure this client so he knows where to go and i do use microprofile config for this so let me see here what i do is i say this [Music] i think i did something wrong here it should have been a a location service but okay let's rename it this is um a location see if this works and then we go here and say that this is conference service it goes to lockloss8484 which is the location service that i created slash data and then slash conference as i have uh slash location as i have here so so if i go in in the browser and if you remember the local it says slash data slash location returns at j focus so let's try and uh call this one and then from the the grid resource i can go in here let's uh use this here what i'm doing is i'll inject oh sorry a um rest client uh and it's a private and in this case it's actually conference service uh even though it's it's actually a location service then uh i don't need this uh the great resource i don't need this one i'm doing a get here uh i'm not producing json anymore i want this a text and what i'm returning here it's just return micro service service talk and then i'm calling the uh comfort service dot conference it's actually location service dot location but uh you get the point there so i'll remove this one and and so i'm injecting this interface i created and i'm calling it here in the typeset way and it should return microservice talk at and then do the call to this one let's see if it actually does it and it doesn't so there's something wrong here so conference let's see it has the location there and say it the configuration says to go low close 80 44 data it should actually be fine but let's restart the the halogen and see if that helps i'm seeing here on the time that we definitely won't be getting through all i plan to do and especially since this one isn't working let's say it says cannot be converted to json okay i get it that's because i'm returning a json object here and we want to return a string there we go and now it's rebuilding and i think it's actually going to work is it sooner there you go let's see come on there we go microsoft talk at jfocus so now i have the the service calling the other service so let's create some more i have a day service and a time service i already have them up and running uh you just have to trust me uh on this i i think this is the day service around 12 the the or time service and day service tuesday at 12. and then uh we want to use the greeting service to call these uh two other services three of their services and and get it rippled through so so so we'll fix the um greeting service to call these uh services so i'm going back to the greeting service in the hello controller i want to add some uh some servers there and i'm actually here i'm using the conference servers because this this is where i should have done it so i'm saying the this this one is actually calling conference and i'm also going to add a day service so this is the same thing i'm using an interface to create the jxrs thing is and i have the time service as well so i'm i'm calling all these i need to configure this service in able to uh in order to be able to run and uh what i have here is the sorry i'll go into the microphone config here and i'll add these configurations so i'm i'm configuring the config service to point to 8082 the time service to a three and three and the day service and also propagating the authorization headers i won't have time for the security part now today but i'll just do it anyway and then i'm going to use these in the uh hello servicer and what i'm going to do is to inject these three interfaces here so i'm injecting all the the services i'm calling and then i'm going to to add the media to type texture and then i'm going to and this one is just to fix the produces that it's great again let's see if it does it afterwards and then i'm going to return the text there you go with that you have a conference and i'm calling the conference service uh and then i'm calling the day service and then i'm calling this one and i'll just see if the imports here are okay so for some reason this one wouldn't works let's skip this one and see if it works without it there you go and uh it should be up and running so let's try it out and go to the um 9080 data hello see if it works oh it wouldn't go so it says protected method int okay i have some uh stuff i haven't done correctly here so i'm not sure why i haven't seen that error before what i'm trying to do is uh if you watch the it code you see the standard answer is have you tried turning it on and off again so i'll do that and see if it works otherwise i think we'll just say the demo if you download [Music] it's getting up and running you see it's it's a little bit faster now than it was the previous time let's see if it works it should be getting up and running oh come on there you go well there is something buggy but it always has to be some bugs in in some talks what i had planned to do was to to get this text you have a microservice talk at j focus 2012 and even add some security on this to secure the the location service here and and then use a json web token from the greeting service that would be propagated through the conference service over and validated at location service and that's it so this is the service i was planning to do and i'm sorry uh the demo didn't work but uh that just uh tells you that you you you'll have to come to my talk another time later because i'm probably doing this again and or you can try it from github and uh i promise you it worked because it did this morning these sources are on my github it's it's called duke's local greeting and it has all the services everything works fine otherwise just ping me and i'll help you get it sorted out microprofile is on microwave.io and jakarta ee uh is on jakarta.ee so that's where you find information so with that i thank you very much for listening and i think we can go over to some q a perfect thank you ever so i will stop stop the recording [Music]
Info
Channel: Jfokus
Views: 93
Rating: undefined out of 5
Keywords:
Id: AQJWDPS8-oc
Channel Id: undefined
Length: 33min 3sec (1983 seconds)
Published: Mon Sep 27 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.