Download presentation
Presentation is loading. Please wait.
Published byFlávio Pedroso Caetano Modified over 6 years ago
1
Build resilient Java Microservices with Eclipse MicroProfile
Emily Jiang, Liberty Architect for MicroProfile and CDI, IBM @emilyfhjiang Antoine Sabot-Durand, Senior Software Engineer on MicroProfile and CDI Spec Lead, Red Emily Jiang – MicroProfile Development Emily starts the presentation and introduce herself. Antoine will then introduce himself.
2
What are Microservices? Small concise service – small piece of SOA
Easy to maintain Easy to release Loosely coupled; A number of them to form a system Microservice best practice Configurable Fault tolerance Monitoring Secure Working well in the cloud How to build it the right way? Use Eclipse MicroProfile Use Spring but more complex Emily talks about Microservice and MicroProfile.
3
Antoine: Thorntail (formerly known as WildFly Swarm) isn't there yet, probably because it has changed to develop MP specs separately as SmallRye so the implementations can be included in both WildFly and Thorntail. You can see the progress of SmallRye here: Tomitribe recently announced TomEE 7.1 and their intention to keep adding more MicroProfile specs very soon: tomee-7-1-release/ Oracle have *very* recently uncovered Helidon, which is starting at MicroProfile 1.1 and will add more features from there: Fujitsu announced Launcher a long time ago, but there is no word (that I have seen) on how they will proceed. They are derived from GlassFish, like Payara, so whether they will collaborate with Payara or SmallRye remains to be seen: KumuluzEE announced support for MP 1.2 a while ago, but I haven't seen much since then: Beyond those, there are a couple of smaller implementations which implement a few specs: Hammock by John Ament is due a 1.2 release soon (according to the website: There's also GuardEE by Matthieu Brouillard which, I think, supports just Config and Fault Tolerance: I think that about covers everything! If you want 2.0 *now* you'll need OpenLiberty or Payara Micro/Payara Server. For the near future, keep an eye on: Thorntail and WildFly (both using SmallRye); TomEE 8.0; Oracle Helidon.
4
What does MicroProfile do?
Vendor-neutral programming model, designed in the open, for Java microservices Provide core capabilities for building fault tolerant, scalable, microservices Increasing the rate and pace of innovation beyond Java EE Standardizing microservices in enterprise Java via the MicroProfile community Config Fault Tolerance Health Check Metrics Security (JWT) Open Tracing Open API Rest Client externalize configuration to improve portability build robust behavior to cope with unexpected failures ensure services are running and meeting SLAs understand the interactions between services while running provides role based access control (RBAC) for microservice endpoints Tracing the microservices invocation chain Easily document microservcie APIs Simplify the creation of rest clients See Graphic shows the community members for MicroProfile who are contributing to the technical direction and development of core capabilities that MicroProfile offers. These form the essential building blocks of microservices and are currently absent from the Java EE specification. By taking a community driven approach to their development, the broader Java developer community can increase the rate and pace of innovation, and prove the technology through the community prior to offering the capabilities to Oracle to standardizes as part of a future Java EE specification. As MicroProfile is an open source Eclipse project, multiple vendors provide implementations of the MicroProfile specification following the tradition of Java EE itself which provides a vendor neutral specification for enterprise application development. This helps optimize the portability of apps built using the MicroProfile specification and avoids vendor lock-in. Invite developers to join the MicroProfile community and influence the future
5
MicroProfile 2.1 release JSON-P 1.1 JAX-RS 2.1 Config 1.3 CDI 2.0
Open Tracing 1.2 Open API 1.0 Rest Client 1.1 JSON-B 1.0 Fault Tolerance 1.1 JWT Propagation 1.0 Metrics 1.1 JWT 1.1 Health Check 1.0 JSON-P 1.1 JAX-RS 2.1 Config 1.3 CDI 2.0 Antoine to talk MicroProfile 2.1 = New = Updated = No change from last release
6
Fault tolerance is about leveraging different strategies to guide the execution and result of some logic. Retry policies, bulkheads, and circuit breakers are popular concepts in this area. They dictate whether and when executions should take place, and fallbacks offer an alternative result when an execution does not complete successfully Antoine to talk
7
CircuitBreaker - @CircuitBreaker Bulkhead - @Bulkhead @Asynchronous
Fault tolerance policies based on CDI interceptor are applied with the following annotations: Retry Timeout CircuitBreaker Fallback Emily to talk
8
Retry: Transient Failure
service A Service B for (int i = 0; i < 5; i++) { try { callServiceC(); break; } catch (IOException e) { } } Emily
9
Retry: Transient Failure
service A service B @Retry(retryOn=IOException.class, delay = 500, maxRetries=5) public void callServiceC() { // call the service } Emily
10
Timeout: Dealing with slow services
service A service B 5s SLA 5s response @Timeout(2000) public void callServiceC() { // call the service } Emily
11
Bulkhead: Restrict resources
service A service B @Bulkhead public void callServiceC() { // call the service } Emily public void callServiceC() { // call the service }
12
CircuitBreaker: Closed
service A service B Antoine
13
CircuitBreaker: Open service A service B Antoine
14
CircuitBreaker: Half-Open
service A service B @CircuitBreaker(failOn=IOException.class, delay = 500) public void callServiceC() { // call the service } Antoine
15
Fallback: handler service A service B @Fallback(MyFallback.class)
public void callServiceC() { // call the service } private class MyFallback implements FallbackHandler { public void handle(ExecutionContext c) { // perform fallback action } Antoine
16
Fallback: method service A service B
@Fallback(fallbackMethod="fallback")public void callServiceC() { // call the service } public void fallback() { //do something Antoine
17
MicroProfile Fault Tolerance with Istio
@Retry @Timeout @CircuitBreaker @Bulkhead @Fallback Retry Timeout CircuitBreaker Bulkhead Emily MicroProfile Fault Tolerance offers Retry, Timeout, Bulkhead, CircuitBreaker, Fallback Istio offers Failure handling: Timeout, retries, limits on number of concurrent connections, circuit breakers Istio can not offer fallback Microservices need both of them sometimes How to set up a ecosystem of MicroProfile Fault Tolerance with Istio Use MicroProfile Fault Tolerance without Istio’s Fault Handling Use Istio’s Fault Handling with MicroProfile Fault Tolerance fallback MicroProfile Fault Tolerance is configurable and flexible The Fault Tolerance policies except fallback can be switched off via a configuration property called MP_Fault_Tolerance_NonFallback_Enabled with the value of false. Unique feature from MicroProfile Fault Tolerance where other Fault Tolerance third party libraries cannot offer easily
18
Demo ServiceA: resilient ServiceB: unreliable Open Liberty
Use MicroProfile RestClient Register Inject MyClient myClient; Bind the client <fully-qualified classname>/mp-rest/url=<backend-service-url>
19
Configure Fault Tolerance parameters parameters test
Configure Fault Tolerance parameters parameters test.ServiceAEndpoint/callserviceB/Retry/maxRetries=5 test. ServiceAEndpoint/callServiceB/Retry/delay=400 test.ServiceAEndpoint/Fallback/fallbackMethod=”anotherFall” test.ServiceAEndpoint/Retry/enabled=false Retry/enabled=false
20
Monitor Fault Tolerance – since FT 1.1
Merics added for Retry, Timeout, CircuitBreaker, Bulkheader and fallback Retry: callsSuccededNotRetires.total, callsSuccededRetired.total, callsFailed.total, retires.total Timeout: executionDuration, callsTimedOut.total, callsNotTimedOut.total CircuitBreaker: circuitbreaker.callsSucceeded.total, circuitbreaker.calls.Failed.total, circuitbreaker.calls.Prevented.total, circuitbreaker.open.total, circuitbreaker.halfOpen.total, circuitbreaker.closed.total, circuitbreaker.opened.total Bulkhead: concurrentExecutions, callsAccepted.total, callsRejected.total, executionDuration, bulkhead.waitingQueue.population, bulkhead.waiting.duration Fallback: fallback.calls.total All of the above metrics name prefixd with ft.<packagename>
21
Resources Code Demo
22
IBM Java Community Party!
Coin-Op Game Room 508 4th Street San Francisco, CA 94107 Wed, October 24, 2018 7:30 PM – 11:00 PM PDT IBM Java Community Party! After Community Keynote We'll be hosting drinks, light food, and video game quarters to help everyone unwind. Chill in the quiet room, or challenge your friends to an epic Pacman Battle Royale! Tell your boss it's "brainstorming". Space is limited, RSVP is required for attendance.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.