SlideShare a Scribd company logo
Building a full stack API with
DevOps integrated
or how to build a complete u-service from scratch in an hour
Sergio Gutierrez
EMEA Senior Solution Architect
Luca Ferrari
EMEA Senior Solution Architect
Agenda
➔ APIs in Microservice Architecture patterns
➔ Quarkus as a runtime engine (advantages)
➔ Development approach: API Contract first / Code first
➔ Demos
1. building your first quarkus api
2. adding fault tolerance
3. observing your u-service
4. adding logging to your service
5. adding persistence
6. adding security (developer friendly way)
APIs in Microservice Architecture patterns
● Synchronous Communication
● Asynchronous Message-based Communication
3
MicroProfile and Microservice Basics
● Java for microservices-based architecture
● Portability across multiple runtimes
The following components are fundamental for developers creating microservices:
● Contexts and Dependency Injection for Java (CDI) specification
● Jakarta RESTful Web Services (JAX-RS)
● JSON processing
Using all three components, you can build basic RESTful web services in a straightforward and declarative
manner.
4

Recommended for you

Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance

In this talk, Carlos de la Guardia shows how a Pyramid application can be deployed using a front end web server, like Apache or Nginx. He also covers how to automate deployment using buildout and a PyPI clone, and post-deployment creation of a variety of maintenance scripts and cron jobs that perform application specific tasks through Pyramid. A link to audio of the presentation is here: http://2011ploneconference.sched.org/event/29a2f357905e4ab0fe3048c53bc1c94c

ploneconf2011pythonpyramid
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3

The document discusses two serverless computing platforms that support Swift - OpenWhisk and Fn. OpenWhisk is an open source system that is event-driven, containerized, and allows chaining of actions. It is hosted on Bluemix but can be difficult to deploy elsewhere. Fn is container-native and deploys functions as containers communicating via standard input/output. Both allow simple Swift functions to be deployed and called remotely with REST APIs or command line tools. The document provides examples of writing, deploying and calling functions on each platform.

openwhiskswiftfnproject
Openwhisk - Colorado Meetups
Openwhisk - Colorado MeetupsOpenwhisk - Colorado Meetups
Openwhisk - Colorado Meetups

An introduction to Apache OpenWhisk, an open source, distributed Serverless platform that executes functions (fx) in response to events at any scale. OpenWhisk manages the infrastructure, servers and scaling using Docker containers so you can focus on building amazing and efficient applications.

apacheopenwhiskserverless
Quarkus advantage
Advantages compared to other Java-based cloud-native frameworks, Quarkus
offers the following benefits:
● Faster response times, in general.
● Lower memory usage.
● Higher throughout in reactive routes.
● Full container image support.
● Compliance to MicroProfile conformance tests.
5
Quarkus advantage
6
Reviewing the JAX-RS Specification
JAX-RS, formerly known as Java API for RESTful Web Services, is a specification that provides support for creating web
services following the Representational State Transfer (REST) architectural pattern.
Annotation Description
@Path The relative path for a class or method.
@GET, @PUT,@POST, @DELETE,
@HEAD
The HTTP request type of a method.
@Produces, @Consumes The Internet media types for the content consumed as the request parameters or
produced as the response. The javax.ws.rs.core.MediaType class specifies the
allowed values.
Table 2.1. JAX-RS Class and Method-Level Annotations Summary
7
Demo #1
How do you get started with this??
Solution: https://quarkus.io/guides/getting-started and git clone https://github.com/quarkusio/quarkus-quickstarts.git
● Bootstrapping an application
● Creating a JAX-RS endpoint
● Injecting beans
● Functional tests
● Packaging of the application
How to create a Hello World API with Quarkus app
8

Recommended for you

Serverless forwardjs
Serverless forwardjsServerless forwardjs
Serverless forwardjs

This document discusses serverless computing and functions as a service. It defines serverless computing as building applications that do not require server management, instead being executed on demand in response to events. It describes how serverless platforms handle tasks like provisioning, maintenance, scaling and billing. Examples of serverless use cases include APIs, backend services, event-driven programming and processing unpredictable traffic. The document then discusses Apache OpenWhisk as an open source serverless platform and how it works.

serverlessopenwhiskibm
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure

Slide deck from my talk on Node.js. More information is available here: http://colinmackay.scot/2014/11/29/dunddd-2014-introduction-to-node-jsfrom-hello-world-to-deploying-on-azure/

azureexpressnode.js
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems

Talk at RubyKaigi 2015. Plugin architecture is known as a technique that brings extensibility to a program. Ruby has good language features for plugins. RubyGems.org is an excellent platform for plugin distribution. However, creating plugin architecture is not as easy as writing code without it: plugin loader, packaging, loosely-coupled API, and performance. Loading two versions of a gem is a unsolved challenge that is solved in Java on the other hand. I have designed some open-source software such as Fluentd and Embulk. They provide most of functions by plugins. I will talk about their plugin-based architecture.

rubyjavaembulk
Demo #1
Bootstrapping the project
quarkus create app org.acme:getting-started 
--extension='resteasy-reactive'
Different options to create your project:
● Maven
● https://code.quarkus.io/
● Quarkus CLI
mvn io.quarkus.platform:quarkus-maven-plugin:2.14.1.Final:create 
-DprojectGroupId=org.acme 
-DprojectArtifactId=getting-started 
-Dextensions='resteasy-reactive'
Quarkus CLI installation https://quarkus.io/guides/cli-tooling
9
Demo #1
Quarkus scaffold project generated
It generates the following in ./getting-started:
● the Maven structure
● an org.acme.GreetingResource resource exposed on /hello
● an associated unit test
● a landing page that is accessible on http://localhost:8080 after starting the application
● example Dockerfile files for both native and jvm modes in src/main/docker
● the application configuration file
10
Demo #2
What if my backend fails?!
The recovery procedures defined by the fault tolerance specification include the following:
● Bulkhead (@org.eclipse.microprofile.faulttolerance.Bulkhead) Limits the workload for a microservice to
avoid failures caused by concurrency or service overload.
● Retry policy(@org.eclipse.microprofile.faulttolerance.Retry) Defines the conditions for retrying a failing
execution.
● Timeout(@org.eclipse.microprofile.faulttolerance.Timeout) Defines the maximum execution time
before interrupting a request.
● Circuit breaker (@org.eclipse.microprofile.faulttolerance.CircuitBreaker)Supports a fail-fast approach
if the system is suffering from an overload or is unavailable.
● Fallback(@org.eclipse.microprofile.faulttolerance.Fallback) Executes an alternative method if the
execution fails for the annotated method.
Source: https://quarkus.io/guides/smallrye-fault-tolerance 11
Demo #2
Fault tolerance - Fallback
@Fallback(fallbackMethod = "fallbackRecommendations")
public List<Coffee> recommendations(int id) {
...
}
public List<Coffee> fallbackRecommendations(int id) {
LOGGER.info("Falling back to
RecommendationResource#fallbackRecommendations()");
// safe bet, return something that everybody likes
return
Collections.singletonList(coffeeRepository.getCoffeeById(1));}
@Fallback(fallbackMethod = "fallbackRecommendations")
> quarkus dev
http://localhost:8080/coffee/2/recommendations
quarkus create app org.acme:microprofile-fault-tolerance-quickstart 
--extension='smallrye-fault-tolerance,resteasy-reactive-jackson 
--no-code
12
The application built in this guide simulates a simple
backend for a gourmet coffee e-shop. It
implements a REST endpoint providing information
about coffee samples we have on store.
In case of a timeout, the page will display a single
recommendation that we hardcoded in our fallback
method fallbackRecommendations(), rather than
two recommendations returned by the original
method.

Recommended for you

Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...

Laravel History, Environment Setup & Laravel Installation MVC architecture, Basic Authentication & Routing Laravel Template Mastering & CRUD Operation Laravel Role Implementation, File storage & Middleware Eloquent ORM & Query Builder, Cart, Session & Others

laravel historyenvironment setuplaravel installation
Migration Spring Boot PetClinic REST to Quarkus 1.2.0
Migration Spring Boot PetClinic REST to Quarkus 1.2.0Migration Spring Boot PetClinic REST to Quarkus 1.2.0
Migration Spring Boot PetClinic REST to Quarkus 1.2.0

In this presentation I will introduce Quarkus and also show which were the steps followed to migrate Spring PetClinic application to Quarkus using the standard libraries : resteasy, microprofile metrics, hibernate, openapi, .... GraalVM

quarkusspringbootgraalvm
Devopstore
DevopstoreDevopstore
Devopstore

This document discusses implementing DevOps practices and technologies like Terraform and Ansible to create a fault-tolerant web store. It outlines creating the VM infrastructure with Terraform including load balancing. Ansible is used to install and configure software. A Jenkins pipeline is created for continuous integration and delivery. A Galera cluster provides database replication across multiple servers. Monitoring and backups are also implemented.

devopsload balancingfault tolerant
Demo #3
I want to observe my u-services!
quarkus create app org.acme:opentelemetry-quickstart 
--extension='resteasy-reactive,quarkus-opentelemetry' 
--no-code
Source: https://quarkus.io/guides/opentelemetry
REST application to demonstrate distributed tracing.
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
13
Demo #3
Open Telemetry
The OpenTelemetry Collector offers a
vendor-agnostic implementation of how to
receive, process and export telemetry
data. It removes the need to run, operate,
and maintain multiple agents/collectors.
This works with improved scalability and
supports open-source observability data
formats (e.g. Jaeger, Prometheus, Fluent
Bit, etc.) sending to one or more
open-source or commercial back-ends.
14
Demo #3
Open Telemetry
15
quarkus dev
-Djvm.args="-Dquarkus.opentelemetry.tracer.exporter.otlp.endpoint=http://localhost:4317"
Demo #4
How can I do simple troubleshooting?
As most developers would say, the first tool to troubleshoot when something goes wrong is logging (everything if
possible).
Quarkus offers JBoss Log Manager and the JBoss Logging facade for this purpose and all the logging configuration can
be done inside your application.properties
Applications and components may use any of the following APIs for logging, and the logs will be merged:
● JDK java.util.logging (also called JUL)
● JBoss Logging
● SLF4J
● Apache Commons Logging
It is possible to change the output format of the console log when for example the output of the application is captured
by a service which can, for example, process and store the log information for later analysis (JSON Logging Format)
16
Source:
https://quarkus.io/guides/rest-json
https://quarkus.io/guides/logging

Recommended for you

Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment

The document discusses various strategies for deploying and maintaining Pyramid web applications. It covers deployment options using Nginx, Apache with mod_wsgi, and Paste. It also discusses using buildout, supervisor, scripting, exception logging, backups, staging environments, caching, monitoring, and replication. The case study at the end describes how the open source KARL project deploys their Pyramid application using Nginx, HAProxy, Paste, Supervisor, buildout, and a custom package index on GitHub.

Kubernetes Java Operator
Kubernetes Java OperatorKubernetes Java Operator
Kubernetes Java Operator

Once you're familiar with Kubernetes and Helm, and still need more integration, what are your options ? Can Java integrate well with Kubernetes ?

kubernetesjavahelm
Spring Live Sample Chapter
Spring Live Sample ChapterSpring Live Sample Chapter
Spring Live Sample Chapter

The document provides instructions on setting up a sample Spring web application using Struts, Spring, and Hibernate. It covers downloading necessary components, creating the project structure and Ant build file, writing a unit test for the persistence layer, configuring Hibernate and Spring, and creating the initial model class and mapping file. The goal is to lay the groundwork for a basic CRUD application to manage user data across the three tiers.

Demo #4
Configuring Logging
We will start from a more comple REST example here
https://github.com/quarkusio/quarkus-quickstarts/tree/main/rest-json-quickstart
This includes: 2 REST resources, Ser/Des, a simple HTML frontend
It also already includes a Logging Filter automatically injected based on ContainerRequestFilter
(https://www.baeldung.com/jersey-filters-interceptors )
We will add more logging at the Resource level, to log as WARN if we add Tomato as a fruit
import org.jboss.logging.Logger;
…
private static final Logger LOG = Logger.getLogger(FruitResource.class);
…
if(fruit.name.equalsIgnoreCase("tomato")){
LOG.warn("Tomato is not a fruit");
}
17
Demo #5
Where to persist data?
Not every information can be stored only in memory, thinking about your amazon order and payment?
Quarkus provides many options to persist data, we will be highlighting the most important:
● Dev Service for DBs: when testing or running in dev mode Quarkus can provide you with a zero-config database
out of the box. Depending on your database type you may need Docker installed in order to use this feature.
Dev Services is supported for the following databases: DB2 (container) (requires license acceptance), Derby (in-process), H2 (in-process), MariaDB
(container), Microsoft SQL Server (container) (requires license acceptance), MySQL (container), Oracle Express Edition (container), PostgreSQL
(container)
● Simple datasource setup: a datasource can be either a JDBC datasource, a reactive one or both. It all depends on
how you configure it and which extensions you added to your project. To define a datasource, start by defining
the kind in the application.configuration. By using a JDBC driver extension and setting the kind in the
configuration, Quarkus resolves the JDBC driver automatically, so you don’t need to configure it yourself
● Support of both Hibernate ORM with Panache:
Hibernate ORM is an object–relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain
model to a relational database.
Panache is a Quarkus-specific library that simplifies the development of your Hibernate-based persistence layer. Similar to Spring Data JPA, Panache
handles most of the repetitive boilerplate code for you. Its implementations of the repository and the active record pattern provide methods to create,
update, and remove records, perform basic queries, and define and execute your own queries.
18
Demo #5
REST with persistence on Postgres container
We will start from a full example which cover everything we have seen in the previous slide
https://github.com/quarkusio/quarkus-quickstarts/tree/main/hibernate-orm-panache-quickstart
This includes: 1 Hibernate with Panache entity, the corresponding REST resource, all implementing the repository pattern
Panache’s repositories provide you with a set of standard methods to find entities by their primary key. You can also persist, update and remove an
entity. The only thing you need to do to get this functionality is to define an entity-specific repository class. It has to implement the
PanacheRepository or PanacheRepositoryBase interface.
We will just modify the configuration so that the db dev service port is fixed, and we can connect to it:
quarkus.datasource.devservices.port=45432
19
Source:
https://quarkus.io/guides/databases-dev-services
https://quarkus.io/guides/datasource
https://quarkus.io/guides/hibernate-orm-panache
https://quarkus.io/blog/quarkus-devservices-testcontainers-podman/
Demo #6
Somebody is bothering me with Security!
As you don’t want to expose your first valuable service publicly without any protection, you might want to think about
security.
Quarkus offers a full range of security options for your services:
● Basic and Form HTTP authentication
● WebAuthn is an authentication mechanism that replaces passwords. When you write a service for registering new users, or
logging them in, instead of asking for a password, you can use WebAuthn, which replaces the password.
● Quarkus also provides mutual TLS (mTLS) authentication so that you can authenticate users based on their X.509
certificates.
● OpenID Connect (OIDC) is an identity layer that works on top of the OAuth 2.0 protocol. OIDC enables client applications to
verify the identity of a user based on the authentication performed by the OIDC provider and to retrieve basic information
about that user. You can also verify ID and access JWT tokens by using the refreshable JSON Web Key (JWK) set or you can
introspect them remotely. However, opaque (binary) tokens can only be introspected remotely.
20
Source: https://quarkus.io/guides/security

Recommended for you

Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications

The document discusses several key technologies for developing Java web applications, including Java Servlet technology, WebWork framework, Spring framework, and Apache Maven build tool. It provides an overview of how each technology addresses common problems like stateless communication, business logic implementation, view generation, and data access overhead. Examples are given showing how WebWork and Spring can be used together with Maven to build a simple "Hello World" application that follows the MVC pattern and leverages dependency injection.

Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems

This document discusses strategies for making Ruby on Rails applications highly available. It covers common architectures using a single server, and moving to distributed systems. Key topics include application modularity, useful gems for asynchronous processing, database replication, session management, application deployment, configuration management, and load balancing. The conclusion emphasizes that porting Rails apps to a highly available environment requires thinking about architecture and distribution early, but is not prohibitively difficult if approached methodically.

ruby rails high availability lvs mongodb
Spring boot microservice metrics monitoring
Spring boot   microservice metrics monitoringSpring boot   microservice metrics monitoring
Spring boot microservice metrics monitoring

This document summarizes a presentation on monitoring microservices with Spring Boot. It discusses evolving architectures from monolithic to microservices and challenges in microservices. It then covers different monitoring techniques like metrics, tracing and logging. It provides an overview of tools like Prometheus, Grafana, Spring Boot Admin, Eureka and Consul for monitoring microservices. Finally, it outlines hands-on labs to set up monitoring of a sample application with different tool combinations.

Demo #6
OIDC security with Security Dev Services
https://github.com/quarkusio/quarkus-quickstarts/tree/main/security-openid-connect-quickstart
You can use the Quarkus OpenID Connect (OIDC) extension to secure your JAX-RS applications using Bearer Token
Authorization. The Bearer Tokens are issued by OIDC and OAuth 2.0 compliant authorization servers, such as Keycloak.
In this example, we are using a very simple microservice which offers two endpoints:
/api/users/me
/api/admin
These endpoints are protected and can only be accessed if a client is sending a bearer token along with the request,
which must be valid (e.g.: signature, expiration and audience) and trusted by the microservice.
The /api/users/me endpoint can be accessed by any user with a valid token. As a response, it returns a JSON document
with details about the user where these details are obtained from the information carried on the token.
The /api/admin endpoint is protected with RBAC (Role-Based Access Control) where only users granted with the admin
role can access. At this endpoint, we use the @RolesAllowed annotation to declaratively enforce the access constraint.
21
Source:
https://quarkus.io/guides/security-openid-connect
Demo #6
BONUS!
In case you can’t find that specific protocol or standard to integrate with inside the standard quarkus libraries,
You can explore the quarkiverse
For example in the case of security we have community support for MFA: https://github.com/quarkiverse/quarkus-mfa
22
Source:
https://quarkus.io/blog/quarkiverse/
Thank you for
staying with us!
23

More Related Content

Similar to Meetup 2022 - APIs with Quarkus.pdf

Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
Nicola Pedot
 
Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)
Katy Slemon
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna Upreti
 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
Jazkarta, Inc.
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
kognate
 
Openwhisk - Colorado Meetups
Openwhisk - Colorado MeetupsOpenwhisk - Colorado Meetups
Openwhisk - Colorado Meetups
Upkar Lidder
 
Serverless forwardjs
Serverless forwardjsServerless forwardjs
Serverless forwardjs
Upkar Lidder
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
Colin Mackay
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
Sadayuki Furuhashi
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
Migration Spring Boot PetClinic REST to Quarkus 1.2.0
Migration Spring Boot PetClinic REST to Quarkus 1.2.0Migration Spring Boot PetClinic REST to Quarkus 1.2.0
Migration Spring Boot PetClinic REST to Quarkus 1.2.0
Jonathan Vila
 
Devopstore
DevopstoreDevopstore
Devopstore
Farkhad Badalov
 
Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment
Carlos de la Guardia
 
Kubernetes Java Operator
Kubernetes Java OperatorKubernetes Java Operator
Kubernetes Java Operator
Anthony Dahanne
 
Spring Live Sample Chapter
Spring Live Sample ChapterSpring Live Sample Chapter
Spring Live Sample Chapter
Syed Shahul
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
hchen1
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
Spring boot microservice metrics monitoring
Spring boot   microservice metrics monitoringSpring boot   microservice metrics monitoring
Spring boot microservice metrics monitoring
Oracle Korea
 
Spring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringSpring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics Monitoring
DonghuKIM2
 
Django deployment with PaaS
Django deployment with PaaSDjango deployment with PaaS
Django deployment with PaaS
Appsembler
 

Similar to Meetup 2022 - APIs with Quarkus.pdf (20)

Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
 
Openwhisk - Colorado Meetups
Openwhisk - Colorado MeetupsOpenwhisk - Colorado Meetups
Openwhisk - Colorado Meetups
 
Serverless forwardjs
Serverless forwardjsServerless forwardjs
Serverless forwardjs
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Migration Spring Boot PetClinic REST to Quarkus 1.2.0
Migration Spring Boot PetClinic REST to Quarkus 1.2.0Migration Spring Boot PetClinic REST to Quarkus 1.2.0
Migration Spring Boot PetClinic REST to Quarkus 1.2.0
 
Devopstore
DevopstoreDevopstore
Devopstore
 
Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment
 
Kubernetes Java Operator
Kubernetes Java OperatorKubernetes Java Operator
Kubernetes Java Operator
 
Spring Live Sample Chapter
Spring Live Sample ChapterSpring Live Sample Chapter
Spring Live Sample Chapter
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
Spring boot microservice metrics monitoring
Spring boot   microservice metrics monitoringSpring boot   microservice metrics monitoring
Spring boot microservice metrics monitoring
 
Spring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringSpring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics Monitoring
 
Django deployment with PaaS
Django deployment with PaaSDjango deployment with PaaS
Django deployment with PaaS
 

More from Red Hat

Meetup 2023 - Gateway API.pdf
Meetup 2023 - Gateway API.pdfMeetup 2023 - Gateway API.pdf
Meetup 2023 - Gateway API.pdf
Red Hat
 
Meetup 2022 - API Gateway landscape.pdf
Meetup 2022 - API Gateway landscape.pdfMeetup 2022 - API Gateway landscape.pdf
Meetup 2022 - API Gateway landscape.pdf
Red Hat
 
APIs at the Edge
APIs at the EdgeAPIs at the Edge
APIs at the Edge
Red Hat
 
Opa in the api management world
Opa in the api management worldOpa in the api management world
Opa in the api management world
Red Hat
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
Red Hat
 
Covid impact on digital identity
Covid impact on digital identityCovid impact on digital identity
Covid impact on digital identity
Red Hat
 
How do async ap is survive in a rest world
How do async ap is survive in a rest world How do async ap is survive in a rest world
How do async ap is survive in a rest world
Red Hat
 
The new (is it really ) api stack
The new (is it really ) api stackThe new (is it really ) api stack
The new (is it really ) api stack
Red Hat
 
The case for a unified way of speaking to things
The case for a unified way of speaking to thingsThe case for a unified way of speaking to things
The case for a unified way of speaking to things
Red Hat
 
What is the best approach to tdd
What is the best approach to tddWhat is the best approach to tdd
What is the best approach to tdd
Red Hat
 
Leverage event streaming framework to build intelligent applications
Leverage event streaming framework to build intelligent applicationsLeverage event streaming framework to build intelligent applications
Leverage event streaming framework to build intelligent applications
Red Hat
 
Using Streaming APIs in Production
Using Streaming APIs in ProductionUsing Streaming APIs in Production
Using Streaming APIs in Production
Red Hat
 
The independence facts
The independence factsThe independence facts
The independence facts
Red Hat
 
Api observability
Api observability Api observability
Api observability
Red Hat
 
Api service mesh and microservice tooling
Api service mesh and microservice toolingApi service mesh and microservice tooling
Api service mesh and microservice tooling
Red Hat
 
Api design best practice
Api design best practiceApi design best practice
Api design best practice
Red Hat
 
Certificate complexity
Certificate complexityCertificate complexity
Certificate complexity
Red Hat
 
Lucamaf1 2949-db--winter2013-accomplishment
Lucamaf1 2949-db--winter2013-accomplishmentLucamaf1 2949-db--winter2013-accomplishment
Lucamaf1 2949-db--winter2013-accomplishment
Red Hat
 
certificate game theory
certificate game theorycertificate game theory
certificate game theory
Red Hat
 
statement of accomplishment - heterogeneous parallel programming
statement of accomplishment - heterogeneous parallel programmingstatement of accomplishment - heterogeneous parallel programming
statement of accomplishment - heterogeneous parallel programming
Red Hat
 

More from Red Hat (20)

Meetup 2023 - Gateway API.pdf
Meetup 2023 - Gateway API.pdfMeetup 2023 - Gateway API.pdf
Meetup 2023 - Gateway API.pdf
 
Meetup 2022 - API Gateway landscape.pdf
Meetup 2022 - API Gateway landscape.pdfMeetup 2022 - API Gateway landscape.pdf
Meetup 2022 - API Gateway landscape.pdf
 
APIs at the Edge
APIs at the EdgeAPIs at the Edge
APIs at the Edge
 
Opa in the api management world
Opa in the api management worldOpa in the api management world
Opa in the api management world
 
How easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performanceHow easy (or hard) it is to monitor your graph ql service performance
How easy (or hard) it is to monitor your graph ql service performance
 
Covid impact on digital identity
Covid impact on digital identityCovid impact on digital identity
Covid impact on digital identity
 
How do async ap is survive in a rest world
How do async ap is survive in a rest world How do async ap is survive in a rest world
How do async ap is survive in a rest world
 
The new (is it really ) api stack
The new (is it really ) api stackThe new (is it really ) api stack
The new (is it really ) api stack
 
The case for a unified way of speaking to things
The case for a unified way of speaking to thingsThe case for a unified way of speaking to things
The case for a unified way of speaking to things
 
What is the best approach to tdd
What is the best approach to tddWhat is the best approach to tdd
What is the best approach to tdd
 
Leverage event streaming framework to build intelligent applications
Leverage event streaming framework to build intelligent applicationsLeverage event streaming framework to build intelligent applications
Leverage event streaming framework to build intelligent applications
 
Using Streaming APIs in Production
Using Streaming APIs in ProductionUsing Streaming APIs in Production
Using Streaming APIs in Production
 
The independence facts
The independence factsThe independence facts
The independence facts
 
Api observability
Api observability Api observability
Api observability
 
Api service mesh and microservice tooling
Api service mesh and microservice toolingApi service mesh and microservice tooling
Api service mesh and microservice tooling
 
Api design best practice
Api design best practiceApi design best practice
Api design best practice
 
Certificate complexity
Certificate complexityCertificate complexity
Certificate complexity
 
Lucamaf1 2949-db--winter2013-accomplishment
Lucamaf1 2949-db--winter2013-accomplishmentLucamaf1 2949-db--winter2013-accomplishment
Lucamaf1 2949-db--winter2013-accomplishment
 
certificate game theory
certificate game theorycertificate game theory
certificate game theory
 
statement of accomplishment - heterogeneous parallel programming
statement of accomplishment - heterogeneous parallel programmingstatement of accomplishment - heterogeneous parallel programming
statement of accomplishment - heterogeneous parallel programming
 

Recently uploaded

Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
shivamt017
 
Splunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptxSplunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptx
sudsdeep
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
avufu
 
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
ThousandEyes
 
ENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentationENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentation
sofiafernandezon
 
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
Semiosis Software Private Limited
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
SSTech System
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
Severalnines
 
Attendance Tracking From Paper To Digital
Attendance Tracking From Paper To DigitalAttendance Tracking From Paper To Digital
Attendance Tracking From Paper To Digital
Task Tracker
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
e-Definers Technology
 
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx
Mitchell Marsh
 
Safe Work Permit Management Software for Hot Work Permits
Safe Work Permit Management Software for Hot Work PermitsSafe Work Permit Management Software for Hot Work Permits
Safe Work Permit Management Software for Hot Work Permits
sheqnetworkmarketing
 
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
onemonitarsoftware
 
dachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdfdachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdf
DNUG e.V.
 
NYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdfNYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdf
AUGNYC
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
sachin chaurasia
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
Ortus Solutions, Corp
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
Ortus Solutions, Corp
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
DNUG e.V.
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
taskroupseo
 

Recently uploaded (20)

Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
 
Splunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptxSplunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptx
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
 
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
 
ENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentationENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentation
 
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
 
Attendance Tracking From Paper To Digital
Attendance Tracking From Paper To DigitalAttendance Tracking From Paper To Digital
Attendance Tracking From Paper To Digital
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
 
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx
 
Safe Work Permit Management Software for Hot Work Permits
Safe Work Permit Management Software for Hot Work PermitsSafe Work Permit Management Software for Hot Work Permits
Safe Work Permit Management Software for Hot Work Permits
 
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
 
dachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdfdachnug51 - All you ever wanted to know about domino licensing.pdf
dachnug51 - All you ever wanted to know about domino licensing.pdf
 
NYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdfNYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdf
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
 

Meetup 2022 - APIs with Quarkus.pdf

  • 1. Building a full stack API with DevOps integrated or how to build a complete u-service from scratch in an hour Sergio Gutierrez EMEA Senior Solution Architect Luca Ferrari EMEA Senior Solution Architect
  • 2. Agenda ➔ APIs in Microservice Architecture patterns ➔ Quarkus as a runtime engine (advantages) ➔ Development approach: API Contract first / Code first ➔ Demos 1. building your first quarkus api 2. adding fault tolerance 3. observing your u-service 4. adding logging to your service 5. adding persistence 6. adding security (developer friendly way)
  • 3. APIs in Microservice Architecture patterns ● Synchronous Communication ● Asynchronous Message-based Communication 3
  • 4. MicroProfile and Microservice Basics ● Java for microservices-based architecture ● Portability across multiple runtimes The following components are fundamental for developers creating microservices: ● Contexts and Dependency Injection for Java (CDI) specification ● Jakarta RESTful Web Services (JAX-RS) ● JSON processing Using all three components, you can build basic RESTful web services in a straightforward and declarative manner. 4
  • 5. Quarkus advantage Advantages compared to other Java-based cloud-native frameworks, Quarkus offers the following benefits: ● Faster response times, in general. ● Lower memory usage. ● Higher throughout in reactive routes. ● Full container image support. ● Compliance to MicroProfile conformance tests. 5
  • 7. Reviewing the JAX-RS Specification JAX-RS, formerly known as Java API for RESTful Web Services, is a specification that provides support for creating web services following the Representational State Transfer (REST) architectural pattern. Annotation Description @Path The relative path for a class or method. @GET, @PUT,@POST, @DELETE, @HEAD The HTTP request type of a method. @Produces, @Consumes The Internet media types for the content consumed as the request parameters or produced as the response. The javax.ws.rs.core.MediaType class specifies the allowed values. Table 2.1. JAX-RS Class and Method-Level Annotations Summary 7
  • 8. Demo #1 How do you get started with this?? Solution: https://quarkus.io/guides/getting-started and git clone https://github.com/quarkusio/quarkus-quickstarts.git ● Bootstrapping an application ● Creating a JAX-RS endpoint ● Injecting beans ● Functional tests ● Packaging of the application How to create a Hello World API with Quarkus app 8
  • 9. Demo #1 Bootstrapping the project quarkus create app org.acme:getting-started --extension='resteasy-reactive' Different options to create your project: ● Maven ● https://code.quarkus.io/ ● Quarkus CLI mvn io.quarkus.platform:quarkus-maven-plugin:2.14.1.Final:create -DprojectGroupId=org.acme -DprojectArtifactId=getting-started -Dextensions='resteasy-reactive' Quarkus CLI installation https://quarkus.io/guides/cli-tooling 9
  • 10. Demo #1 Quarkus scaffold project generated It generates the following in ./getting-started: ● the Maven structure ● an org.acme.GreetingResource resource exposed on /hello ● an associated unit test ● a landing page that is accessible on http://localhost:8080 after starting the application ● example Dockerfile files for both native and jvm modes in src/main/docker ● the application configuration file 10
  • 11. Demo #2 What if my backend fails?! The recovery procedures defined by the fault tolerance specification include the following: ● Bulkhead (@org.eclipse.microprofile.faulttolerance.Bulkhead) Limits the workload for a microservice to avoid failures caused by concurrency or service overload. ● Retry policy(@org.eclipse.microprofile.faulttolerance.Retry) Defines the conditions for retrying a failing execution. ● Timeout(@org.eclipse.microprofile.faulttolerance.Timeout) Defines the maximum execution time before interrupting a request. ● Circuit breaker (@org.eclipse.microprofile.faulttolerance.CircuitBreaker)Supports a fail-fast approach if the system is suffering from an overload or is unavailable. ● Fallback(@org.eclipse.microprofile.faulttolerance.Fallback) Executes an alternative method if the execution fails for the annotated method. Source: https://quarkus.io/guides/smallrye-fault-tolerance 11
  • 12. Demo #2 Fault tolerance - Fallback @Fallback(fallbackMethod = "fallbackRecommendations") public List<Coffee> recommendations(int id) { ... } public List<Coffee> fallbackRecommendations(int id) { LOGGER.info("Falling back to RecommendationResource#fallbackRecommendations()"); // safe bet, return something that everybody likes return Collections.singletonList(coffeeRepository.getCoffeeById(1));} @Fallback(fallbackMethod = "fallbackRecommendations") > quarkus dev http://localhost:8080/coffee/2/recommendations quarkus create app org.acme:microprofile-fault-tolerance-quickstart --extension='smallrye-fault-tolerance,resteasy-reactive-jackson --no-code 12 The application built in this guide simulates a simple backend for a gourmet coffee e-shop. It implements a REST endpoint providing information about coffee samples we have on store. In case of a timeout, the page will display a single recommendation that we hardcoded in our fallback method fallbackRecommendations(), rather than two recommendations returned by the original method.
  • 13. Demo #3 I want to observe my u-services! quarkus create app org.acme:opentelemetry-quickstart --extension='resteasy-reactive,quarkus-opentelemetry' --no-code Source: https://quarkus.io/guides/opentelemetry REST application to demonstrate distributed tracing. <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-opentelemetry</artifactId> </dependency> 13
  • 14. Demo #3 Open Telemetry The OpenTelemetry Collector offers a vendor-agnostic implementation of how to receive, process and export telemetry data. It removes the need to run, operate, and maintain multiple agents/collectors. This works with improved scalability and supports open-source observability data formats (e.g. Jaeger, Prometheus, Fluent Bit, etc.) sending to one or more open-source or commercial back-ends. 14
  • 15. Demo #3 Open Telemetry 15 quarkus dev -Djvm.args="-Dquarkus.opentelemetry.tracer.exporter.otlp.endpoint=http://localhost:4317"
  • 16. Demo #4 How can I do simple troubleshooting? As most developers would say, the first tool to troubleshoot when something goes wrong is logging (everything if possible). Quarkus offers JBoss Log Manager and the JBoss Logging facade for this purpose and all the logging configuration can be done inside your application.properties Applications and components may use any of the following APIs for logging, and the logs will be merged: ● JDK java.util.logging (also called JUL) ● JBoss Logging ● SLF4J ● Apache Commons Logging It is possible to change the output format of the console log when for example the output of the application is captured by a service which can, for example, process and store the log information for later analysis (JSON Logging Format) 16 Source: https://quarkus.io/guides/rest-json https://quarkus.io/guides/logging
  • 17. Demo #4 Configuring Logging We will start from a more comple REST example here https://github.com/quarkusio/quarkus-quickstarts/tree/main/rest-json-quickstart This includes: 2 REST resources, Ser/Des, a simple HTML frontend It also already includes a Logging Filter automatically injected based on ContainerRequestFilter (https://www.baeldung.com/jersey-filters-interceptors ) We will add more logging at the Resource level, to log as WARN if we add Tomato as a fruit import org.jboss.logging.Logger; … private static final Logger LOG = Logger.getLogger(FruitResource.class); … if(fruit.name.equalsIgnoreCase("tomato")){ LOG.warn("Tomato is not a fruit"); } 17
  • 18. Demo #5 Where to persist data? Not every information can be stored only in memory, thinking about your amazon order and payment? Quarkus provides many options to persist data, we will be highlighting the most important: ● Dev Service for DBs: when testing or running in dev mode Quarkus can provide you with a zero-config database out of the box. Depending on your database type you may need Docker installed in order to use this feature. Dev Services is supported for the following databases: DB2 (container) (requires license acceptance), Derby (in-process), H2 (in-process), MariaDB (container), Microsoft SQL Server (container) (requires license acceptance), MySQL (container), Oracle Express Edition (container), PostgreSQL (container) ● Simple datasource setup: a datasource can be either a JDBC datasource, a reactive one or both. It all depends on how you configure it and which extensions you added to your project. To define a datasource, start by defining the kind in the application.configuration. By using a JDBC driver extension and setting the kind in the configuration, Quarkus resolves the JDBC driver automatically, so you don’t need to configure it yourself ● Support of both Hibernate ORM with Panache: Hibernate ORM is an object–relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database. Panache is a Quarkus-specific library that simplifies the development of your Hibernate-based persistence layer. Similar to Spring Data JPA, Panache handles most of the repetitive boilerplate code for you. Its implementations of the repository and the active record pattern provide methods to create, update, and remove records, perform basic queries, and define and execute your own queries. 18
  • 19. Demo #5 REST with persistence on Postgres container We will start from a full example which cover everything we have seen in the previous slide https://github.com/quarkusio/quarkus-quickstarts/tree/main/hibernate-orm-panache-quickstart This includes: 1 Hibernate with Panache entity, the corresponding REST resource, all implementing the repository pattern Panache’s repositories provide you with a set of standard methods to find entities by their primary key. You can also persist, update and remove an entity. The only thing you need to do to get this functionality is to define an entity-specific repository class. It has to implement the PanacheRepository or PanacheRepositoryBase interface. We will just modify the configuration so that the db dev service port is fixed, and we can connect to it: quarkus.datasource.devservices.port=45432 19 Source: https://quarkus.io/guides/databases-dev-services https://quarkus.io/guides/datasource https://quarkus.io/guides/hibernate-orm-panache https://quarkus.io/blog/quarkus-devservices-testcontainers-podman/
  • 20. Demo #6 Somebody is bothering me with Security! As you don’t want to expose your first valuable service publicly without any protection, you might want to think about security. Quarkus offers a full range of security options for your services: ● Basic and Form HTTP authentication ● WebAuthn is an authentication mechanism that replaces passwords. When you write a service for registering new users, or logging them in, instead of asking for a password, you can use WebAuthn, which replaces the password. ● Quarkus also provides mutual TLS (mTLS) authentication so that you can authenticate users based on their X.509 certificates. ● OpenID Connect (OIDC) is an identity layer that works on top of the OAuth 2.0 protocol. OIDC enables client applications to verify the identity of a user based on the authentication performed by the OIDC provider and to retrieve basic information about that user. You can also verify ID and access JWT tokens by using the refreshable JSON Web Key (JWK) set or you can introspect them remotely. However, opaque (binary) tokens can only be introspected remotely. 20 Source: https://quarkus.io/guides/security
  • 21. Demo #6 OIDC security with Security Dev Services https://github.com/quarkusio/quarkus-quickstarts/tree/main/security-openid-connect-quickstart You can use the Quarkus OpenID Connect (OIDC) extension to secure your JAX-RS applications using Bearer Token Authorization. The Bearer Tokens are issued by OIDC and OAuth 2.0 compliant authorization servers, such as Keycloak. In this example, we are using a very simple microservice which offers two endpoints: /api/users/me /api/admin These endpoints are protected and can only be accessed if a client is sending a bearer token along with the request, which must be valid (e.g.: signature, expiration and audience) and trusted by the microservice. The /api/users/me endpoint can be accessed by any user with a valid token. As a response, it returns a JSON document with details about the user where these details are obtained from the information carried on the token. The /api/admin endpoint is protected with RBAC (Role-Based Access Control) where only users granted with the admin role can access. At this endpoint, we use the @RolesAllowed annotation to declaratively enforce the access constraint. 21 Source: https://quarkus.io/guides/security-openid-connect
  • 22. Demo #6 BONUS! In case you can’t find that specific protocol or standard to integrate with inside the standard quarkus libraries, You can explore the quarkiverse For example in the case of security we have community support for MFA: https://github.com/quarkiverse/quarkus-mfa 22 Source: https://quarkus.io/blog/quarkiverse/
  • 23. Thank you for staying with us! 23