You're reading from Hands-On Enterprise Java Microservices with Eclipse MicroProfile
Chapter 1
-
An enterprise Java microservice has the following features:
- It is written using the Java language.
- It can use any Java framework.
- It can use any Java APIs.
- It must be enterprise-grade: reliable, available, scalable, secure, robust, and performant.
- It must fulfill the characteristics of microservice architectures as listed at https://martinfowler.com/microservices/, which are as follows:
- Componentization via services
- Organized around business capabilities
- Products not projects
- Smart endpoints and dumb pipes
- Decentralized governance
- Decentralized data management
- Infrastructure automation
- Design for failure
- Evolutionary design
- The terms digital economy and digital transformation describe the convergence of four different forces that are changing the needs of businesses: mobile, cloud, IoT, and open source.
- Businesses need to adapt to the new demands of the digital...
Chapter 2
- The main means of communication for the MicroProfile community is their Google Group, called Eclipse MicroProfile. You can post a message to it by sending an email to microprofile@googlegroups.com. Another great way to get your voice heard is by attending the bi-weekly MicroProfile Hangout call. Please check the MicroProfile Google Calendar to find out the exact date, time, and meeting information to join.
- The MicroProfile Hangout call serves as a forum where topics brought up by attendees are discussed and decisions are made, from sub-project statuses and release contents to release dates and sub-project creation approvals.
- A sub-project (MicroProfile specification) lead or a group of leads are usually subject-matter experts in the topic at hand and are designated to serve as its facilitators. One important aspect to note is that the lead or leads of a working group...
Chapter 3
- The default sources of configuration properties are environment variables, Java system properties, and the META-INF/microprofile-config.properties file.
- You can provide a custom ConfigSource implementation that maps property names to values in the custom source.
- Strings are not the only supported types, as MP-Config supports type conversion via a pluggable SPI, and provides several default conversions by default.
- You do not need to provide a value for an injected property if you have given a defaultValue, or have injected the property as an Optional<?> value.
- Complex property types can be handled using a custom Converter<?> implementation that takes a string and returns the complex type.
- When an annotation is specified at the class level, it applies to all methods of the class.
- False: there are currently six MP-FT policies.
- No: we can configure @Retry to...
Chapter 4
- The wire format is not usable in environments that only look at the HTTP status code to determine the HC status.
- An MP-HC response can include arbitrary properties using the HealthCheckResponse#withData() methods.
- You can create a HealthCheck implementation for each service, and the MP-HC feature will logically combine them to produce an overall status response.
- A JWT is a JSON Web Token, a JSON-formatted object that has a header, payload, and signature component.
- A claim is a single named value from the JWT payload.
- Anything that can be represented in JSON can be used in a JWT.
- The single main step in authenticating a JWT is validating that it is signed via the RS256 algorithm based on a configured public key.
- One could look at claims other that the groups claim to make checks to add application specific authorization decisions.
Chapter 5
- Distributed tracing provides a micro-view of what happened with a request from end to end, whereas metrics expose scalar numerical values from a single component.
- Distributed tracing systems usually provide features such as the root cause and critical path analysis, contextualized logging, distributed context propagation, and service dependency diagrams.
- Automatically traced are JAX-RS server endpoints and MicroProfile Rest clients. Some vendors can also automatically trace JAX-RS clients.
- These tags are added for every REST request http.method, http.status_code, http.url, component, span.kind and error if an exception is thrown.
- Explicit instrumentation can be added by using @Traced annotation or injecting the tracer and creating spans manually.
- There are three scopes: base for server metrics that apply to all runtimes, vendor for metrics that are server-specific,...
Chapter 6
- No: by default, any REST endpoint will have OpenAPI generated for it even if none of the MP OpenAPI annotations are used.
- Yes: you can choose to use as many or as few of the MP OpenAPI annotations as you wish, to represent the REST endpoints in your microservice.
- The notion is that you predefine the expected contracts of your endpoints and encapsulate these in OpenAPI documents that can be bundled with your microservice.
- No: you just need to know what the formats of the request and response are, and then you can create your own type-safe interface.
- By using the .../mp-rest/url MP Config setting, where ... is either the interface name of the type-safe interface or the configKey passed to the RegisterRestClient annotation.
- One way is to register a ClientHeadersFactory implementation. Another is to list the headers in the org.eclipse.microprofile.rest.client.propagateHeaders...
Chapter 7
- At the time of writing, there are eight implementations of Eclipse MicroProfile, all of which are open source. They are Thorntail, Open Liberty, Apache TomEE, Payara Micro, Hammock, KumuluzEE, Launcher, and Helidon. There is also Quarkus as the latest entrant.
- An application server is a container for Java EE applications. An application assembler only includes the functionality that the application needs, instead of requiring an application server to be up and running, and commonly generates an executable JAR. An application assembler can generate an uberjar, a self-contained runnable JAR file, or an application jar with its runtime dependencies located in a sub-directory, for example, an accompanying lib or libs sub-directory.
- Here is a short description of the current eight MicroProfile implementations on the market:
- Red Hat are the sponsors of the open source Thorntail...
Chapter 8
- We have seen many examples throughout the book and this chapter that MP-Config settings affect both application and MP features.
- As long as the path you supplied exists, you should be able to see a successful heath check with information about that path.
- It shows information about the KeyCloak server. If KeyCloak is stopped, it shows an error.
- It will not be found because the metric is generated lazily on first request.
- TBD.
- For unsecured methods the behavior should be similar. For secured methods, the Swagger-UI invocations fail.
- You will see error responses.
- That is the encoded MP-JWT. You can use that in a curl command as the Authorization: Bearer ... header value where you would replace the ... with the string found in the Access Base64 Token field.
Chapter 9
- MicroProfile Reactive Messaging is a great option for handling message sources via connectors, especially in situations where the source is generating messages at a high frequency and an asynchronous approach to processing them makes the most sense.
- MicroProfile Context Propagation best supports MicroProfile Reactive Streams Operators and MicroProfile Reactive Messaging in that it allows the propagation of context that was traditionally associated with the current thread across various types of units of work.
- The current specifications that support reactive programming are MicroProfile Reactive Streams Operators, MicroProfile Reactive Messaging, and MicroProfile Context Propagation.
- At the time of writing, the projects that sit outside the Eclipse MicroProfile umbrella release are as follows:
- Reactive Streams Operators
- Reactive Messaging
- Long Running Actions
- Context...
Chapter 10
- Eclipse MicroProfile provide one of the best approaches to develop microservices using enterprise Java. In turn, microservices developed using containers as their unit of deployment provide one of the best approaches to develop highly distributed systems in the cloud and on-premises, that is, cloud-native applications. Hence, MicroProfile-based microservices facilitate the development of cloud-native applications.
- There are two complementary aspects or components to cloud-native application development: application services and infrastructure services. Application services speed up the development of business logic of a cloud-native application, and infrastructure services speed up its delivery and deployment. These two aspects are complementary and integral to cloud-native application development.
- Cloud-native application development is an approach to building and...
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Enterprise Java Microservices with Eclipse MicroProfilePublished in: Aug 2019Publisher: PacktISBN-13: 9781838643102
© 2019 Packt Publishing Limited All Rights Reserved
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime