SlideShare a Scribd company logo
Implementing Cloud-Native
Architectural Patterns with
Micronaut
Naresha K

@naresha_k

https://blog.nareshak.com/
About me
Developer, Coach, Consultant
Founder & Organiser
Bangalore Groovy User Group
https://github.com/cncf/toc/blob/master/DEFINITION.md
https://www.redhat.com/en/topics/cloud-native-apps#
https://www.redhat.com/en/topics/cloud-native-apps#
Implementing Cloud-Native Architectural Patterns with Micronaut
Externalised Configuration
Configuration coupled with code
https://blog.nareshak.com/if-you-are-building-your-artifacts-per-environment-you-are-doing-it-wrong/
“Configuration should be
version controlled”
Configuration coupled with code
Externalising the configuration
@Controller("/hello")
public class HelloController {
@Value("${greeting.message}")
private String message;
@Get("/")
@Produces(MediaType.TEXT_PLAIN)
public String index() {
return message;
}
}
micronaut:
application:
name: hello-service
greeting:
message: Hello from Micronaut
java -Dmicronaut.environments=uat -jar
hello-service-0.1.jar
Configuration Injection
java -Dgreeting.message="Hello from External Config”
-jar hello-service-0.1.jar
java -Dmicronaut.config.files=“/tmp/external-config.yml"
-jar hello-service-0.1.jar
Is this not enough?
Config Server
Config
Server
Application
Application
Application
docker run -p 8500:8500 consul
Implementing Cloud-Native Architectural Patterns with Micronaut
Implementing Cloud-Native Architectural Patterns with Micronaut
bootstrap.yml
curl -X PUT -d @- localhost:8500/v1/kv/config/greet-service/greeting.message <<< "Hello from Consul"
~ curl http://localhost:8080/greet
Hello from Consul
Service Discovery
Cloud Infrastructure
Microservices
Service
Registry
Service
X
Service A
Service
Registry
Service
X
Service A
Register
Service
Registry
Service
X
Service A
Register
Service
Registry
Service
X
Service A
Get routing information
Service
Registry
Service
X
Service A
REST call
Implementing Cloud-Native Architectural Patterns with Micronaut
Implementing Cloud-Native Architectural Patterns with Micronaut
---
consul:
client:
registration:
enabled: true
defaultZone: "${CONSUL_HOST:localhost}:${CONSUL_PORT:8500}"
application.yml
sample-service ./gradlew run
> Task :run
05:12:07.121 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 1260ms. Server Running: http://localhost:8080
05:12:07.251 [nioEventLoopGroup-1-3] INFO i.m.d.registration.AutoRegistration - Registered service [sample-service] with Consul
http://localhost:8080/greet
@Controller("/hello")
class HelloController {
@Inject
GreetClient greetClient
@Get("/")
String index() {
greetClient.index()
}
}
Implementing Cloud-Native Architectural Patterns with Micronaut
Resilience /
Fault Tolerance
https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing
07:19:19.838 [pool-1-thread-2] ERROR i.m.r.intercept.RecoveryInterceptor - Type
[com.nareshak.demo.GreetClient$Intercepted] attempting to resolve fallback for unavailable service
[sample-service]
07:19:19.843 [pool-1-thread-2] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred:
No available services for ID: sample-service
io.micronaut.discovery.exceptions.NoAvailableServiceException: No available services for ID: sample-
service at
io.micronaut.http.client.loadbalance.AbstractRoundRobinLoadBalancer.getNextAvailable(AbstractRoundRo
binLoadBalancer.java:50)
Timeout
07:33:47.976 [pool-1-thread-3] ERROR i.m.r.intercept.RecoveryInterceptor - Type [com.nareshak.demo.GreetClient$Intercepted]
executed with error: Read Timeout
io.micronaut.http.client.exceptions.ReadTimeoutException: Read Timeout
Retry
@Retryable
String callExtService(){
}
@Retryable(attempts = "3", delay = "5s")
String callExtService(){
}
Implementing Cloud-Native Architectural Patterns with Micronaut
07:26:27.347 [pool-1-thread-2] ERROR i.m.r.intercept.RecoveryInterceptor - Type [com.nareshak.demo.GreetClient$Intercepted]
attempting to resolve fallback for unavailable service [sample-service]
07:26:37.355 [pool-1-thread-2] ERROR i.m.r.intercept.RecoveryInterceptor - Type [com.nareshak.demo.GreetClient$Intercepted]
attempting to resolve fallback for unavailable service [sample-service]
07:26:52.361 [pool-1-thread-2] ERROR i.m.r.intercept.RecoveryInterceptor - Type [com.nareshak.demo.GreetClient$Intercepted]
attempting to resolve fallback for unavailable service [sample-service]
07:27:12.373 [pool-1-thread-2] ERROR i.m.r.intercept.RecoveryInterceptor - Type [com.nareshak.demo.GreetClient$Intercepted]
attempting to resolve fallback for unavailable service [sample-service]
07:27:12.378 [pool-1-thread-2] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: No available services for
ID: sample-service
io.micronaut.discovery.exceptions.NoAvailableServiceException: No available services for ID: sample-service
at
io.micronaut.http.client.loadbalance.AbstractRoundRobinLoadBalancer.getNextAvailable(AbstractRoundRobinLoadBalancer.java:50)
Circuit Breakers
Implementing Cloud-Native Architectural Patterns with Micronaut
@CircuitBreaker
String callExtService(){
}
@CircuitBreaker(reset = "40s")
String callExtService(){
}
Implementing Cloud-Native Architectural Patterns with Micronaut
Fallback
@Fallback
class FallbackClient implements GreetClient{
@Override
String index() {
return "Default Message"
}
}
Implementing Cloud-Native Architectural Patterns with Micronaut
API Versioning
@Get(“/greet")
String index() {
"Hello"
}
@Get(“/greet")
Single<String> indexV2() {
Single.just("Hello V2")
}
@Get(“/greet")
@Version("1")
String index() {
"Hello"
}
@Get(“/greet")
@Version("2")
Single<String> indexV2() {
Single.just("Hello V2")
}
router:
versioning:
enabled: true
header:
enabled: true
names:
- 'X-API-VERSION'
- 'Accept-Version'
application.yml
~curl http://localhost:8080/greet -H "X-API-VERSION: 1"
Hello%
~ curl http://localhost:8080/greet -H "X-API-VERSION: 2"
Hello V2%
@Client("sample-service")
@Version("1")
interface GreetClient {
@Get("/greet")
String index()
@Version("2")
@Get("/greet")
Single<String> indexV2()
}
When you in are in cloud-native world, features like fault tolerance,
service discovery, externalised configuration are necessary
Micronaut makes it easier to implement these patterns with its built-in support
Conclusion
Thank You

More Related Content

PDF
OpenNebula Conf 2014 | Puppet and OpenNebula - David Lutterkort
PDF
Celery
PPTX
Guice gin
PPTX
Sapphire Gimlets
PDF
"Full Stack frameworks or a story about how to reconcile Front (good) and Bac...
PDF
using Queue Server for batch processing
PDF
Introduction to Celery
PDF
ember-socket-guru - common api for websockets providers
OpenNebula Conf 2014 | Puppet and OpenNebula - David Lutterkort
Celery
Guice gin
Sapphire Gimlets
"Full Stack frameworks or a story about how to reconcile Front (good) and Bac...
using Queue Server for batch processing
Introduction to Celery
ember-socket-guru - common api for websockets providers

Similar to Implementing Cloud-Native Architectural Patterns with Micronaut (20)

PDF
Micronaut Launchpad
PPTX
Micronaut brainbit
PDF
Java Cloud Native Hack Nights GDL
PDF
Microservices with Micronaut
PPTX
Discover Micronaut
PDF
Introduction to Micronaut
PDF
Implementing Resilience with Micronaut
PDF
Micronaut: Changing the Micro Future
PPTX
Microservices with kubernetes @190316
PDF
SpringBoot and Spring Cloud Service for MSA
PPTX
Building 12-factor Cloud Native Microservices
PDF
Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
PDF
Introduction to Micronaut at Oracle CodeOne 2018
PPTX
Building a scalable microservice architecture with envoy, kubernetes and istio
PDF
Microservices with Spring Cloud and Netflix OSS
PDF
Micronaut Deep Dive - Codeone 2019
PDF
Microservices on a budget meetup
PDF
Microservices - Hitchhiker's guide to cloud native applications
PDF
Introduction to Micronaut - JBCNConf 2019
PDF
Microservices DevOps on Google Cloud Platform
Micronaut Launchpad
Micronaut brainbit
Java Cloud Native Hack Nights GDL
Microservices with Micronaut
Discover Micronaut
Introduction to Micronaut
Implementing Resilience with Micronaut
Micronaut: Changing the Micro Future
Microservices with kubernetes @190316
SpringBoot and Spring Cloud Service for MSA
Building 12-factor Cloud Native Microservices
Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
Introduction to Micronaut at Oracle CodeOne 2018
Building a scalable microservice architecture with envoy, kubernetes and istio
Microservices with Spring Cloud and Netflix OSS
Micronaut Deep Dive - Codeone 2019
Microservices on a budget meetup
Microservices - Hitchhiker's guide to cloud native applications
Introduction to Micronaut - JBCNConf 2019
Microservices DevOps on Google Cloud Platform
Ad

More from Naresha K (20)

PDF
The Groovy Way of Testing with Spock
PDF
Evolving with Java - How to Remain Effective
PDF
Take Control of your Integration Testing with TestContainers
PDF
Take Control of your Integration Testing with TestContainers
PDF
Favouring Composition - The Groovy Way
PDF
Effective Java with Groovy - How Language Influences Adoption of Good Practices
PDF
What's in Groovy for Functional Programming
PDF
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
PDF
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
PDF
Eclipse Collections, Java Streams & Vavr - What's in them for Functional Pro...
PDF
Groovy - Why and Where?
PDF
Leveraging Micronaut on AWS Lambda
PDF
Groovy Refactoring Patterns
PDF
Implementing Cloud-native Architectural Patterns with Micronaut
PDF
Effective Java with Groovy
PDF
Evolving with Java - How to remain Relevant and Effective
PDF
Effective Java with Groovy - How Language can Influence Good Practices
PDF
Beyond Lambdas & Streams - Functional Fluency in Java
PDF
GORM - The polyglot data access toolkit
PDF
Rethinking HTTP Apps using Ratpack
The Groovy Way of Testing with Spock
Evolving with Java - How to Remain Effective
Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
Favouring Composition - The Groovy Way
Effective Java with Groovy - How Language Influences Adoption of Good Practices
What's in Groovy for Functional Programming
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Eclipse Collections, Java Streams & Vavr - What's in them for Functional Pro...
Groovy - Why and Where?
Leveraging Micronaut on AWS Lambda
Groovy Refactoring Patterns
Implementing Cloud-native Architectural Patterns with Micronaut
Effective Java with Groovy
Evolving with Java - How to remain Relevant and Effective
Effective Java with Groovy - How Language can Influence Good Practices
Beyond Lambdas & Streams - Functional Fluency in Java
GORM - The polyglot data access toolkit
Rethinking HTTP Apps using Ratpack
Ad

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Cost to Outsource Software Development in 2025
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Website Design Services for Small Businesses.pdf
PPTX
assetexplorer- product-overview - presentation
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PPTX
history of c programming in notes for students .pptx
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
Nekopoi APK 2025 free lastest update
CHAPTER 2 - PM Management and IT Context
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
Design an Analysis of Algorithms I-SECS-1021-03
iTop VPN Free 5.6.0.5262 Crack latest version 2025
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Design an Analysis of Algorithms II-SECS-1021-03
Advanced SystemCare Ultimate Crack + Portable (2025)
Cost to Outsource Software Development in 2025
Monitoring Stack: Grafana, Loki & Promtail
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Website Design Services for Small Businesses.pdf
assetexplorer- product-overview - presentation
Weekly report ppt - harsh dattuprasad patel.pptx
history of c programming in notes for students .pptx
Computer Software and OS of computer science of grade 11.pptx
AutoCAD Professional Crack 2025 With License Key
Salesforce Agentforce AI Implementation.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development

Implementing Cloud-Native Architectural Patterns with Micronaut