 Two sessions of the afternoon and the day. I want to just welcome Hans Peter and also thanks. I'm Peter is he's coming from Austria So it's a long flight for him. So welcome to the stage. Thank you. Well, hello and welcome everyone Thanks for joining this afternoon session We want to share and explain to you today how you can build cloud native applications with a modern stack called quarkus and and The idea is that you walk away first with knowing what quarkus is if you don't know that know know it already second Why it might be a great fit for your next Java project and third and most importantly We also want to show you something after doing some some introductory slides So we have two blocks of live coding Planned for that session so that you see and and get a first impression and feeling how You know convenient and joyful development these days for Java apps has become thanks to Quarkus now before diving in a few quick words about ourselves Yeah, I'm based in Austria, which is pretty much in the center of Europe. I'm a developer advocate here at Red Hat Feel free to reach out to me and stay in touch on Twitter. I'm quite active there if Twitter is not your thing Yeah, you can use my email address and drop me a line any time I'm really appreciate that I can do this session together with Neha Who will also do and join us later than for the second part of the demo, please introduce yourself briefly Hi, all I'm Neha Gupta associate specialist solution architect at Red Hat and I work with enterprises to help them in moving towards you know, how they can utilize the open-source technology and Create a futuristic architecture, which is cloud ready also modernize. So that was like a short introduction about me Thank you. Thank you. We will see more of you then during the demo part So whenever something new pops up on the horizon such as Quarkus, it wasn't there forever, right? It was Introduced at one point. You've seen it probably in the keynote earlier today they introduced later than spring boot You might legitimate the question. Why should you look into something new? Why does it make sense to find yet another way to develop Java applications? And I think there are a couple of reasons but one is Related to a certain amount of overhead that is there when we run Java applications This overhead is to some degree Related to startup times that might be slower for Java apps than for lower level languages But more so there is a higher memory consumption usually for Java application This becomes particularly interesting and important when we run in containers now several Here in the audience are probably too young to remember that there was once a time where the overhead we are referring to on that slide Essentially didn't matter. You could forget about it. It was a time where we Basically started and bootstrapped very large enterprise software on application servers running on really beefy machines but you know the industry changed and in recent years and today of course we do something else also Java moved forward and It's used today for many different other types of of applications than just monoliths and so if you have things like other architectures in mind microservices or Maybe you want to write your serverless functions with Java then this overhead from the previous slide becomes Very very important. It can hurt us a lot It starts to matter a lot the more fine-grained and the more distributed our software architectures become And so what is caucus and how can it help us with with those challenges in particular when we have cloud native? Applications in mind. So one of the first things you find is that caucus is specifically tailored for Kubernetes native workloads this very often means again to reiterate that using newer architectural Styles such as microservices and serverless runtime such as k-native But the important thing to understand is it doesn't have to be like that So if all you wish for is a monolithic application It's perfectly fine to use caucus for that as well and build your monolith with caucus That's very often something that people tend to forget because Irrespective of what architectural style we are aiming at caucus basically brings the same Tooling the same benefits and the same great developer experience So it this is totally detached from the architecture you have in mind And so we're gonna see some of those things that caucus brings regarding developer experience later in the two Life coding blocks as well, but just to give you a few hints upfront There is something that is called the death mode in caucus and this death mode has a couple of really nice things One is that we have life reload functionality This is maybe something when you're coming from another background like no chess that you say well Yeah, we have that for ages, but in Java. This is not Something that you could commonly rely on we will see that then in addition to that the death mode has a suite of So-called dev services that it brings to the table and what that dev services do for us is they automatically Detect what extensions what dependencies we add to our project and when those dependencies refer to External services such as databases caches Messaging systems and things like that a caucus will automatically spin Containers up in the background for us and run a postgres database or a MongoDB database or an infinite bank cache or Kafka and it does that without any need of configuration in in the application properties So it just works and then finally Building native executables also something that is particularly interesting when you have serverless scenarios in mind here caucus seamlessly basically interacts with Graviem and uses Graviem's native image Compilation functionality to build native executables out of these Java applications So another important aspect that's often forgotten when it comes to developer experiences freedom of choice So the idea is not that caucus tries to impose a particular way of of writing your code onto you You can choose whatever best fits your use case and in this case I'm referring to Both programming models that you have available in caucus you can use the imperative way of writing code But other developers in particular those that might come from other language backgrounds They might want to do reactive programming and that's also fine With with caucus it doesn't have to be a strict either or decision You can just like use even if you want to and need that mix and match both of these programming models in the same application Now we also mentioned cloud native a couple of times already and with it comes the necessity to Well containerize our applications and workloads and I think it's not an exaggeration to say that caucus has been built from the ground up with containers in mind and What's most important to know about that is not these observable benefits that are listed here But the actual results we get out of these benefits. So caucus builds Artifacts for us that are optimized in disk size Which in turn leads to smaller container images then the Optimized artifacts that caucus builds They are tend to start up faster considerably faster in particular when we would use native executable And this is then a very good fit for instantaneous scale-out needs that we might have in serverless scenarios and finally the in general lower resource consumption CPU as well as memory means of course we have higher deployment at densities that we can achieve in our Kubernetes environment so at the end of the day we can save money by by doing that And so all of these are really desired properties for containers But there's more to it like when we think about wanting to have applications that run on Kubernetes They should have several fundamental capabilities from an application perspective things like Offering metrics having health check endpoints offering debugging and tracing Mechanisms so that we can figure out when we have problems what's going wrong with the application and then of course also We want to configure and use like config maps secrets and and and other kubernetes Resources and inject them into the container and all of that basically supported out of the box with Quarkus and everything you develop with Quarkus also builds on open standards like Many of you I'm sure are familiar with those standards that are listed here So we can do dependency injection using a subset of the cdi a bin specification We can write our rest endpoints using chucks RS We can use JPA and JTA annotations for transactional persistence So all of that we have fused also in the past in in in one way or another is there in Quarkus as well many other things as well So no Quarkus does not reinvent the wheel in all these areas It just like brings together and builds upon really battle-dested and popular libraries and technologies all of which are open source Now there's just one more thing that I want to figure out together with you quickly before we go to the to the hands-on part And it's what's the secret sauce if you want to behind Quarkus And so I think it's key in that regard to understand the fundamentally Different way that Quarkus takes for building applications when you compare it to more traditional stacks of frameworks first a traditional way We just write our code. We compile it its package together with all the dependencies into a deployable artifacts Say a runnable char so not much things are happening at build time usually Then when we run the application a lot of things start to happen framework mechanisms kick in config file baths in class bath loading class baths canning Annotation and other metadata processing runtime code generation to build Dynamic proxies and all other sorts of things that are time and consuming and resource intensive And our Quarkus addresses exactly that and tries to do it in an opposite way It tries to move as many of the activities that are resource and time intensive to the build phase So this means when the time comes that we want to run our build artifact Most of these things have already been done up front and this is also basically the reason why it can Start significantly faster and also with consistently lower memory usage Talking about this the bottom line is that with Quarkus we do more at build time so that we need to work less at runtime and When it comes to the runtime again, we have two options usual the usual option still heavily used is to take our build Artifacts and run them on the JVM. This is perfectly fine But then again, you can use gravity M to compile down those Build artifacts to native executables. Thanks to this native image functionality of gravity M But with that, let's move to the life coding part and see some of the stuff in action Okay, so for that, let me go out of the slides quickly. Let me just check I have a mini cube up and running here So my local Kubernetes if you want to and I'm going to use the Quarkus CLI to create an app from scratch It's a very admittedly very simple app, but it suffices to show most of the things regarding Developer experience that you get so let me switch into that folder. Let me fire up Visual Studio code quickly. So this is a project. It was generated by the Quarkus CLI It uses Maven as the build tool. You could also use Gradle if you prefer that. I'm getting old So I'm sticking to Maven here. So the project structure is pretty familiar We have a Java folder test folder in in the sources. We have application properties They are empty and I'm going to spin up one or two terminals real quick Let me do that and then I Mentioned the dev mode right and this dev mode again. You if you use the CLI you just say Quarkus dev and then The application It says automatically scaffolded from the CLI will start, okay And now it's up and running and we will come back to that in a few moments again, but we can go there Just open the application. This is a static index page that was auto-generated and we have also Automatically because we have some demo codes there also generated a simple rest endpoint So it says just hello from rest easy reactive So it's a palm file that was scaffolded and it uses just a couple of of dependencies and settings there that were Automatically set up like I said during this Quarkus create application command and so with that Let's see some of the code here. So this resource chucks are as resource was automatically generated Let me just make a very simple change at first and remember the application is just running. I'm hitting safe I'm going to the browser. I'm hitting refresh and It's refreshed. Okay. So, yeah, okay. This change is basically a static constant string, but let's do a couple of more things here Let's take the API and make a different path for that resource or so maybe add Another path definition down here. Let's say this is agreed Endpoint under API agreed and let's give it some Even like path parameter so that we can choose who we agreed. We can change the method name here We use the path parameter that gets injected from from the From the rest call here. It's a string. Let's make it a string. Let's say who and let's use that here Let's say hi and add who here so if we do that and go back to the browser again, I just Saved I obviously have to change that here to API slash Slash Neha, let's greet Neha my co-speaker here and it says hi Neha So we changed a couple of things right we can also do more things we can make more changes that are Reloaded life as we code along we can introduce configuration properties. Okay using the eclipse micro profile Specification here. Let's introduce a custom greeting here just to have some Thing that gives a little bit of more dynamic nature to that application and let's call it custom greeting as well Well, it reminds us immediately. We have we don't have that property. So if we go there, we see yes That's true. There is no property custom greeting. Let's say good afternoon Okay, I hit save again. I go here let's refresh and Nothing happens, right? Nothing happens. The reason nothing happens is maybe you spotted it I didn't use the configuration property yet So that was a pretty clear that nothing happens so far But let's say custom greeting and then add that down here again refresh and we have good afternoon Neha so we can also live reload like Things from coming from the application properties that get injected and I never had to stop Restart re recompile or any other like explicit interaction was needed for doing that So with that Let's figure out one more thing. Remember. We said support for Kubernetes support for containers and usually this means things like okay, you need to come up with a docker file somehow or you need to write some YAML and Fight the YAML syntax and stuff like that, but it doesn't have to be like that So let me go to the command line here real quick and here I'm cheating a little bit so that I don't have to type and mistype the names But what we basically do is we ask the Quarkus CLI to add two extensions here the Quarkus Kubernetes extension and A second one the container image chip extension So chip is a Google project to build containers without docker files Basically to sum it up quickly and now that we have those two things We can just add a couple of configuration properties. Let me do that real quick here and I'm going to explain that soon I'm just adding that and run Quarkus build down here now that we made some changes that are Related to how we want this application to be built by Quarkus We say we want to have a char file as an output. We want a container that need that should get built Yeah, here we have some some issue. Let's let's see what what we have. Oh, yeah, see we have a test failure So we quickly fix because we're all good developers. I don't want to skip those tests. Let me quickly fix the test Okay, that's important because also a test was generated here and just so that you see that how this works Quarkus does continuous testing so it realized. Oh, there's something wrong with the test So let's quickly fix the test here together. We again inject that property here And then we can of course adapt the test real quick Path param it's called path param say who Not how but who then we greet Nihar again in the test then we say this is API greet who and then We say we just fix the expected Output if we do that so we should have our custom greeting Followed by that followed by who and ideally let me go back to the command line resume and check the tests Tests are still not running fine and the reason is There is probably small Typo in my tests. Yeah here, of course, this has to be Nihar as well This is a fixture here. So let's see the test runs. It's passing again. So now the build should pass again So continuous testing is something very nice because you see immediately when you break something in your code So that was good that this happened and then we're gonna build that and when we build that now All the tests are running. They are running fine. And so what it does is it builds a container image for us And it also is going to deploy that container into my mini cube environment locally. Okay So this is about to finish very soon So when I go here then to the command line, so the build process is done It now builds the container image and here you see it deploys to kubernetes server It's mini cube on my local machine. It applied a service and a deployment to that Now if you take a look at that here real quick, we have this pot up and running and this pot is Let's just check the logs quickly cube CTL logs for that pot It's our caucus application serving the rest endpoint and to simply to quickly verify that we can expose that service here real quick and this gets into my browser and then forwards that into the application running in a container in my kubernetes bot and I'm here on the same index page that we have Seen earlier and so I'd say API greets Everyone I want to greet everyone and it says good afternoon everyone out of the pot and the container that that pot Is running and remember we haven't even touched a docker file We haven't even touched a yaml file and and this happens automatically in the background so let me just show that to you real quick and Then I'm basically done already. So this is the yaml file that was automatically scaffolded behind the scenes It uses a kubernetes service here to expose the deployment that is created down here And you are the container was created. Let's take a look at that quickly as well And then I'm about to finish so we have that container that I built about a minute ago And this is the container that was deployed to that kubernetes environment that basically concludes this short quick demo of showing you the interactive nature and the live reload functionality in a couple of other things that Quarkus brings to the table with that I'm done and I want to switch over to the to Neha for the second part of the demo She's showing us a little bit about how we can work with existing applications Existing applications that might have even been written with with a different framework such as spring and she shows you how to Do a migration for that. Thank you for now Thank you hands Peter by now you might have all got pretty much idea about how caucus works and How easily you can get started with it? You don't need to you know, learn much of a coding It's basically explain you what I'm going to do in the demo So what I will be doing is I have one application which is written in spring board and it's a to-do task management system It is full flash developed in spring MVC using, you know, JPA and then interacting with the Database also having a swagger UI in built-in the application So what we will do is we will migrate this application from spring board to Quarkus framework And we will use a some tool which is known as MPA and also known as red hat Migration toolkit for application. So with the help of that tool We will be analyzing the application as a first step and once we analyze the issues which you know Steps which are needed to fix the sorry to migrate my application From spring board to Quarkus, we will be fixing each of those issues and after fixing then the application should be you know, very well Capable enough to run in a caucus method. So right now. I'm in a red hat code ready studio and this is my application code So nothing to, you know, go deep dive over here. I will what I will do is I will quickly run this application And what it is doing is it is in the background using a postgres SQL database, which is running as a container on my machine So I'll be starting that database first just to explain you the command. What I'm doing is I'm starting the my postgres Container and passing some of the environment variables such as what will be the username and password in order to connect to the DB So let's start the database So now our DB is up and running. Let's go and start the application So I'm in my project directory already. So if I do ls so I can see all the files Let us start the application. So we'll be using maven wrapper for starting the application So now the application is started. Let's try to you know, check if it's running properly or not Okay, so here is the application. Let's try to add some task to it Okay, once added, you can, you know, just play around with it. You click it and if you want to delete it and What thing I wanted to show you in this application was this below green line where we can see the Support of open API standard 3 then we have an inbuilt swagger UI. So I'll just I'll just clicking on it We also have a swagger UI, which you know comes with some set of RESTful APIs directly using this API is you can interact with your applications and Then it pretty much gives you a you know metrics prometheus gives you the metrics using which you can get the details about what is the heap size What is the memory size the application using using to run? Then there is one more mapping which is out of the health point which tells you whether your application is up and running So this is how the application runs. Okay. So now let us do The analysis of the application. So I wanted to I told you I told you about the MTA, right? So I'll be going and showing you that So just to get you idea about what migration toolkit for application is It's an migration toolkit mostly for the Java based applications and you use this tool to analyze your application Not only analysis, but also, you know, do the actual migration you can Download this application It's like pre open source like if you want to explore the product You can just go to the download link and it's available in different varieties. So you can run it as a container You can run it as a web console on your local environment. Then there is a CLI version also available So just for the sake of saving time I will be using the MTA CLI version to interact with it without installing it on my local machine and What this tool will do it will check my all the source code line And then it will analyze it. It will create a report dashboard for me. So let's run the you know command for Creating the report So what is it is doing is this MTA is starting and you can see the version as well which it is showing it is 5.3 and What it will do is it will scan the code and then create a report and store it at some place So I'm just waiting for it to complete the report analysis And then we will go through the list and analyze the application that what are the issues or what are the things needed to change in order You know for my application to move from Springboard to Quarkus. It's a very beautiful tool Let me tell you because I have used it and we have done some Workshop as well for our customers where we have migrated their application from you know Java monolithic Java application to the Cloud native application and we have also done the platform re-platform So it not only supports the migration of application It provides you different if you know the six are factors for migrating or modernizing your application So there are different factors like refactoring re-platforming or re-hosting So it tells you that whether your application what kind of you know change is required. So let me Go to the report So here is something the report is getting stored So once loaded you can see it is telling you the list of applications So right now this is my application in which I have you know scanned my project This 32 is the number of points or you can see the number of incidents which this Tool has identified as a you know the things to change in the application. So Let me go in the project Once you go it gives you a graphical view about the How many number of incidents are mandatory like they are needed to change how many are potential Which means like they might cause issues going further. So it's better to you change them and then some information Which you might know about your application So just to check the issues in our current application. I will go into the issue sections So Yeah, so these are the list of mandatory issues and here I would like you to focus on one of the issues Let me just quickly check it This one so replace the spring parent form with a caucus bomb So what it is telling if I click on it It gives you the detail about the you know issue detail like it is telling replace the spring parent application because it Is not supported in caucus. It also gives you the reference link So in case you don't know what are the format and how to implement it in the code You can quickly go to it and then just Write it in your code accordingly So it also tells you the line of code at where the it has identified So we can see the file name the issue is in the file name form dot XML, so I'll be going in form dot XML and If you see over here, it is highlighting all the number of lines where the change needs to be done So such as it was mentioning to replace the palm fire palm parent form directory, right? So this is line number four then it is also telling us to replace some of the dependencies like spring web Which is not supported in caucus. So it is also giving you the links like what can be used as a replacement for those So let us go and make these changes in our application based on this suggestions, which the report has suggested us So I'll be going back to my source code. So this is my palm dot XML. So here if you see Line number four, right? Here is the parent directory. I can remove it Then it mentioned about spring web. So all the dependencies which are related to spring, right? Basically, I'll be removing all of them Now we have to add each of them whatever we have removed So just to save time what I have done is I have already created the updated palm dot XML with all the caucus library So I'll use that like use that file Let me just add it then I'll explain it what we have what changes we have made so I Will say we have already migrated our application from spring boot to caucus because we have basically changed the entire dependencies or entire libraries which was needed for your application to run as a spring boot and now we are Suggesting them to use the caucus one. So here if you see all the libraries which were mentioned earlier We're using a spring web and all now they are you know referring to the IO dot caucus repository and Similarly for building your application. It is using a Marvin plugin. So we have defined that as well over here. So Let's go and do the rerun of your report. So I'll come back here and then rerun my application But before doing that, let me stop the application which was running previously, right? Thus in the spring version Clean it and also stop the DB Meanwhile, it is standing scanning my application. I'll just do the clean So earlier when we run this application, it was running as a spring if you can see the banner. This is to up. Sorry But it was running as a spring. Now, let's run it as caucus So we will be running our application in caucus dev mod and now It changed, right? Let's go and access the application. It's working as it is. And also, let's try to access this points like swagger Okay, so these things are not working which indicates like we have not fully migrated our application like some of the properties Piles are left. So I had already run the report. So let me check if it got generated or not Okay, so report is generated. Let me check if We can see the latest report Okay, so yeah The number of incidents have been reduced since we have already fixed all the issues which were related to dependency file And let's go. What are these issues? So if we see over here, it is representing the issue in the application property file Which means some of the data sources which were defined from spring board Can not be run in the, you know, caucus framework and we will have to change it according to caucus and Yeah, so this is the same then this is also for that only Okay, most of them are related to data source. If you see all APIs which we are trying to access the mapping points like Open API or swagger in all of them the issues are there. So which means we have to change those file so let's go back in the code ready and Yeah, this is the file which it is representing or may be indicating the issues are there Here we have defined all the endpoints as well as the you know details to connect with the database So what we will do is we will change it With the supported ones. I think now the application should work as it is Yeah, here it is So did you notice one thing I did not went to the terminal to restart my application or recompile which is one of the you know benefit of caucus dev mode and Also, if you notice it is well interacting with DB for spring boot one I started DB manually, but when I started my caucus application, I did not started the DB. What it does Let me show you here in console in dev mode if you can read somewhere it shows that It has started the data source. So the property files, which we updated here this hypernate ORM database it automatically created a data schema for my application And I did not have to go and start the you know postgres database manually So this was the you know a simple way of showing you how you can migrate your existing application This is one way of migration, but there are many different ways you might have complex complex applications and Where you might need to do code level changes here What we change was more on a configuration level or property level or you can say the dependencies level But when you have annotations defined such as a spring boot annotation in your application So you also have to replace those kind of changes. So that is come that comes under the refactor of you know the factor kind of migration. So this was one way and then Obviously, there are other ways which are available on you know This mta tool how you can use it to migrate it and this was all about the demo. I believe and I'm done So we are wrapping it up here. We have just two Three quick quick call for action here. So if you want to get started with partners This is where you probably want to start if you're new to it code of partners. I own There is one to learn more people. There's a really nice people enterprise shop applications also free to use Finally, you don't want to play around with local mini cube or something like that and check out the developer sandbox It's a free fully managed open shift environment that you can use for 30 days That's it. Thanks a lot for joining us and maybe we have time for one or two quick questions Thanks a lot. Is caucus is currently used in the production environment for any of the application Can you say again? I had is this caucus is used in the production environment for any of the applications Of course, of course there are a couple of a couple of customers that are using it redhead customers But also like people that are just using like the the upstream open source project. There is a redhead support There's a specific version of caucus as well for which you can get support I was just showing the the open source version Where they migrated their application So in the in caucus you said The most of the things will be done at the build time rather than a run time, right? So is that a dependency over let's say we are using spring boot, right? There is a new feature which has come in a spring in a newer version But that is not being supported by the caucus. How do we get through that? So the question was related also to to the spring spring native I think some library. I'm using yeah You use spring native you mean? Yeah. Yeah, okay, and you you we were wondering. What's the the main difference? So there is a new version has come let's say with a new feature of it But because it is comfortable the caucus, right? We need to get a caucus base dependency For our project, right if we are using caucus so you mean for migrating. Yeah, yeah That's definitely something where where I think you mentioned that already that not all not not everything that spring has is Supported in in terms of of annotations for instance there you can find the caucus adds extensions Basically every version brings new and more spring support But you cannot like rely on every spring feature that it would be available as of today in caucus Maybe you want to add something about that? Thanks again, and enjoy the rest of the day. Thank you