diff --git a/chapter01/chapter01.adoc b/chapter01/chapter01.adoc new file mode 100644 index 00000000..7a72d89e --- /dev/null +++ b/chapter01/chapter01.adoc @@ -0,0 +1,278 @@ += Chapter 1: Introduction to MicroProfile + +== Introduction + +This introductory chapter provides a comprehensive overview of the MicroProfile platform, setting the stage for subsequent chapters in this tutorial. It aims to familiarize you with the fundamentals of the MicroProfile platform, its need, and benefits. Finally, we will discuss its place in the broader context of enterprise Java development. + +== Topics to be covered: +- What is MicroProfile +- Need for MicroProfile +- MicroProfile Specifications +- Current MicroProfile Implementations +- Architecture Philosophy +- Benefits of MicroProfile +- Relationship with Jakarta EE specification + +== What is MicroProfile + +link:https://microprofile.io/[MicroProfile] is an open-source specification that enhances enterprise Java technologies for microservices development. It provides a set of APIs and specifications for building modern, scalable, resilient, and efficient microservices-based applications. The primary goal of MicroProfile is to simplify the development for Java developers, enabling them to create applications optimized for cloud-native-development. + +MicroProfile was initiated in June 2016 by a collaboration of industry leaders, Java community members, and individual contributors. In the following year, the project was transitioned to the link:https://www.eclipse.org/[Eclipse Foundation] to enhance the project's openness and vendor-neutral stance. Now, MicroProfile has become a key framework for extending Java in the cloud-computing domain, offering a comprehensive suite of APIs tailored for developing microservices in a cloud-native ecosystem. + +The *MicroProfile Working Group* currently comprises of the following members: + +Committer Representative (Year 2024) + + * Emerson Castañeda + +Java user groups + + * Atlanta Java User Group (AJUG) + * Association of the German Java User Groups (iJUG) + +Corporate Members + + * IBM + * Fujitsu + * Red Hat + * Primeton + * Payara + * Microsoft + * Tomitribe + * Oracle + +This collective effort demonstrates MicroProfile's commitment to evolving Java enterprise development for the modern cloud environment, leveraging the expertise of its community. + +== Need for MicroProfile + +The MicroProfile Specification was developed to address the following requirements: + +- *Microservices Architecture Adoption*: The industry shift towards microservices architecture has brought several advantages, including improved flexibility, scalability, and speed of deployment. However, it also introduced several new challenges for developers due to the added complexities. These include ensuring seamless integration between microservices, securing each microservice individually as well as interactions between them, managing performance and efficiency, designing microservices to be fault-tolerant and resilient to failures, ensuring data consistency across services, managing configurations across multiple environments and managing various independently deployable components. To address these challenges, MicroProfile provides a simplified and optimized set of APIs designed to build and deploy Java-based microservices applications. + +- *Limitations of Traditional Enterprise Java*: Traditional enterprise Java frameworks, like Java EE (now Jakarta EE), were often seen as too monolithic and heavyweight for microservices while evolving too slowly. It led to a demand for a more streamlined and microservices-focused framework. MicroProfile fills this gap by providing a lightweight alternative optimized for microservices development. + +- *Cloud-Native Application Development*: The rise of cloud-native applications necessitated new features such as external configuration, health checks, and fault tolerance, which existing Java standards did not adequately address. MicroProfile bridges these gaps left, making it easier for developers to create resilient, scalable, and manageable microservices for cloud-native application development using Java. + +- *Community-Driven Innovation*: The rapid pace of technological change in microservices necessitated a collaborative platform for innovation. MicroProfile, backed by community and vendor support, promotes rapid evolution to meet these demands. + +- *Vendor Neutrality and Interoperability*: There was a need for a framework that could provide standardization across different implementations and environments, ensuring compatibility and avoiding vendor lock-in. + +- *Focus on Simplicity and Productivity*: Developers needed a simple, easy-to-understand framework that increased productivity by reducing boilerplate code and focusing on essential microservice functionalities. Well-defined standards and patterns eliminate the need to reinvent the wheel, allowing developers to focus on microservices logic. + +- *Support for familiar programming model*: MicroProfile was founded with support for Jakarta JSON Processing, Jakarta JSON Binding, Jakarta RESTful Web Services, and Jakarta Contexts and Dependency Injection (CDI) to define the core programming model and accelerate adoption. + +- *Lightweight and Resilient Services*: With the microservices architecture, there's a need for frameworks that support the development of lightweight, resilient, and independently deployable services, which are essential for microservices. + +- *Rapid Adaptation to New Trends*: The technology landscape, especially around microservices, is constantly evolving. A framework like MicroProfile, which is community-driven and rapidly evolving, can adapt quickly to these changes, continually incorporating new practices and technologies, including: + ** *Streaming APIs and Reactive Programming Model*: To facilitate non-blocking communication and data processing, enhancing system responsiveness and scalability. + ** *API-First Development (Open API)*: Emphasizing the design and documentation of microservices with an API-first approach, promoting interoperability and clear service contracts. + ** *Eventual Consistency and Long Running Actions (LRA)*: Addressing the challenges of data consistency in distributed systems without compromising system performance. + +- *Enhanced Observability and Monitoring*: Microservices architectures complicate application monitoring and observability. A framework with built-in support for these capabilities simplifies the management of distributed services. + +== MicroProfile Specifications + +MicroProfile specifications are divided into two main categories: Platform and Standalone. + +:figure-caption: Figure +.MicroProfile Specifications +image::http://microprofile.io/wp-content/uploads/2023/10/microprofile_release_6.1.png[MicroProfile 6.1] + +=== MicroProfile Platform Component Specifications + +The MicroProfile Platform Specification is the core set of MicroProfile specifications designed to provide the foundational functionalities needed for microservices development. These specifications solve specific microservices challenges, including configuration, fault tolerance, health checks, metrics, and security. The table below provides a list of platform specifications of MicroProfile along with their descriptions: + +[options="header"] +|======================= +|Specification |Description +|link:https://microprofile.io/specifications/microprofile-config/[Config] | Provides an easy-to-use and flexible system for application configuration. +|link:https://microprofile.io/specifications/microprofile-fault-tolerance/[Fault Tolerance]| Implements patterns like Circuit Breaker, Bulkhead, Retry, Timeout, and Fallback for building resilient applications. +|link:https://microprofile.io/specifications/microprofile-jwt-auth/[JWT Authentication]| Defines a standard for using OpenID Connect (OIDC) based JSON Web Tokens(JWT) for role-based access control(RBAC) of microservices endpoints for secure communication. +|link:https://microprofile.io/specifications/microprofile-metrics/[Metrics] | Define custom application metrics and expose platform metrics on a standard endpoint using a standard format to external monitoring systems. +|link:https://microprofile.io/specifications/microprofile-health/[Health] | Allows applications to expose their health and readiness to perform operations to the underlying platform, which is crucial for automated recovery in cloud environments. +|link:https://microprofile.io/specifications/microprofile-open-api/[Open API] | Facilitates the generation of OpenAPI documentation for RESTful services, making API discovery and understanding easier. +|link:https://microprofile.io/specifications/microprofile-telemetry/[Telemetry]| Provides a unified set of APIs, libraries, and tools for collecting, processing, and exporting telemetry data (metrics, traces, and logs) from cloud-native applications and services. +|link:https://microprofile.io/specifications/microprofile-rest-client[Rest Client]| Defines a type-safe approach to invoke RESTful services over HTTP(S), simplifying the development of Rest clients. +| link:https://jakarta.ee/specifications/coreprofile/10/[Jakarta EE Core Profile 10] | An optimized Jakarta EE platform designed specifically for developing microservices and cloud-native Java applications with a reduced set of specifications for a lighter runtime footprint. +|======================= + +=== Standalone (Outside Umbrella) Specifications + +Standalone specifications address more advanced needs that every microservices application may not require. They allow for innovation and experimentation in areas that are evolving or where there’s a need to address niche concerns without burdening the core platform with additional complexity. The table below provides a list of standalone specifications of MicroProfile along with their descriptions: + +[options="header"] +|======================= +|Specification |Description +| link:https://microprofile.io/specifications/microprofile-context-propagation/[Context Propagation] | Defines a way to propagate context between threads and managed executor services. Ensure that the context is consistent during executing asynchronous tasks or across different services. +| link:https://microprofile.io/specifications/microprofile-graphql/[GraphQL] | Provides a layer on top of Jakarta EE that allows the creation of GraphQL services. This specification makes it easier to build APIs, enabling clients to request exactly the data they need and nothing more. +| link:https://microprofile.io/specifications/microprofile-lra/[Long Running Actions (LRA)]| Focuses on providing a model for developing services that participate in long-running processes, ensuring consistency and reliability without necessarily locking data. +| link:https://microprofile.io/specifications/microprofile-reactive-messaging/[Reactive Messaging]| Aims to facilitate building applications that communicate via reactive streams, enabling the development of event-driven, responsive, and resilient microservices. +| link:https://microprofile.io/specifications/microprofile-reactive-streams-operators/[Reactive Streams Operators]| Provides a way to process data streams in a reactive manner, allowing for non-blocking system design and improving the efficiency of data processing in microservices. +| link:https://microprofile.io/specifications/microprofile-opentracing/[Open Tracing]| Integrates distributed tracing by defining a way for services to trace requests across service boundaries, improving observability. +|======================= + +== MicroProfile Implementations +Below is the list of MicroProfile Implementations, each offering a platform for building and running microservices-based applications: + +- link:https://www.payara.fish/products/payara-micro/[Payara Micro^] +- link:https://tomee.apache.org/[Apache TomEE^] +- link:https://openliberty.io/[Open Liberty^] +- link:https://github.com/fujitsu/launcher[Launcher^] +- link:https://quarkus.io/[Quarkus^] +- link:https://www.wildfly.org/[WildFly^] +- link:https://helidon.io/[Helidon^] + +== Architecture Philosophy + +The overall goal of MicroProfile architecture is to provide a lightweight enterprise-grade framework tailored for building cloud-native applications and enabling developers to build and deploy microservices with Java easily: + +- *Simplicity*: MicroProfile APIs are designed to be simple and easy to use. They avoid unnecessary complexity and focus on providing the essential functionality for building microservices. + +- *Modularity*: Its modular approach allows developers to use only what they need, reducing the overhead typically associated with enterprise frameworks. + +- *Standards-based*: MicroProfile is based on open standards and specifications, ensuring compatibility and consistency across different implementations. + +- *Community-driven*: It encourages active participation from the Java community for continuous evolution. + +- *Vendor-Neutral*: MicroProfile is vendor-neutral. It’s supported by several industry players, ensuring that no single company controls its direction. + +- *Focus on Cloud-Native Applications*: The architecture is specifically tailored for cloud environments. MicroProfile integrates with a number of cloud-native technologies, such as Kubernetes and Istio. This makes it easy to deploy and manage MicroProfile applications in cloud environments. + +- *Reactive programming*: MicroProfile supports reactive programming, which is a style of programming that is well-suited for building microservices. Reactive applications are responsive and scalable, and they can handle high volumes of concurrent requests. + +:figure-caption: Figure +.Architecture Philosophy of MicroProfile +image::/images/figure1-2.png[Architecture Philosophy of MicroProfile] + +=== Benefits of MicroProfile +MicroProfile offers several benefits, making it a compelling choice for developing microservices, especially in Java-centric environments. These benefits include: + +- *Optimized for Microservices*: MicroProfile is designed explicitly for creating microservices, offering APIs that cater to the unique challenges of this architectural style. + +- *Cloud-Native Focus*: The framework includes features such as externalized configuration, health checks, and metrics, which are essential for building and operating cloud-native applications effectively. MicroProfile is inherently designed for cloud-native applications. + +- *Open Source and Standards-Based*: As an open-source framework based on open standards, MicroProfile facilitates interoperability and reduces the risk of vendor lock-in. + +- *Enhanced Productivity, Rapid Development and Deployment*: MicroProfile simplifies microservices development with a set of standard APIs. With its focus on simplicity and productivity, MicroProfile helps speed up the development and deployment of microservices by providing essential functionalities and reducing boilerplate code. + +- *Community-Driven Innovation*: Being community-driven, MicroProfile evolves quickly, incorporating new trends and best practices in microservices development. MicroProfile is backed by a strong Java community, ensuring continuous improvement and support. + +- *Vendor Neutrality*: Being vendor-neutral, MicroProfile is supported by a wide range of industry players, which ensures a broad choice of tools and platforms for developers. + +- *Compatibility with Jakarta EE*: MicroProfile is complementary to Jakarta EE, whether using MicroProfile implementations that support a small subset of Jakarta EE (such as Core Profile) or implementations that extend the full Jakarta EE Platform implementations with MicroProfile. + +- *Lightweight and Modular*: It provides a lightweight model compared to traditional enterprise Java frameworks. Its modularity allows developers to use only the necessary components, reducing the application's footprint and overhead. + +- *Scalability*: The framework supports the development of scalable applications, essential for microservices that handle varying loads efficiently. + +- *Enhanced Resilience*: MicroProfile includes specifications for fault tolerance patterns like retries, circuit breakers, timeouts, and bulkheads, which are crucial for building resilient services that can withstand network and service failures. + +- *Security Features*: MicroProfile's JWT Authentication provides a standardized way to secure microservices, making it easier to implement authentication and authorization. + +- *Ease of Testing*: With its lightweight nature and support for advanced features like Rest Client, MicroProfile simplifies the testing of microservices, both in isolation and in integration scenarios. + +== Relationship with Jakarta EE specification + +Jakarta EE is an open specification with more than 40 component specifications to address a wide array of needs of enterprise Java development. MicroProfile complements this by providing a baseline platform definition that optimizes enterprise Java for microservices architecture and delivers application portability across multiple compatible runtimes. Many Jakarta EE implementations that target a broad array of applications supplement Jakarta EE with MicroProfile to better support microservices. Their coexistence allows developers to harness the strength of both platforms, thereby facilitating a more versatile and adaptive approach to modern enterprise and cloud-native application development. MicroProfile strategically leverages Java EE developers' existing skill sets, enabling them to transition and adapt to microservices development with minimal learning curve. This ensures that developers can easily design and implement microservices architecture, enhancing productivity and facilitating the creation of cloud-native applications. Later in this tutorial, we will explore how MicroProfile API extends Jakarta EE’s capability to address microservices-specific challenges. + +NOTE: MicroProfile and Jakarta EE are complementary technologies. Both platforms enable developers to stay at the forefront of cloud-native application development. + +== Conclusion + +In this section, we explored the MicroProfile platform in detail, laying the foundation for understanding how it revolutionizes the development of microservices using Java. We started by defining MicroProfile, emphasizing its role as an open-source specification tailored for microservices development. Key contributions from industry leaders and community members have positioned MicroProfile as a pivotal technology in the Java ecosystem, especially for cloud-native application development. We delved into the essential specifications of MicroProfile, each playing a critical role in addressing specific challenges in microservices development, from configuration management to service resilience. As we move forward in this tutorial, we will delve deeper into each specification and discover how to implement MicroProfile in real-world Java applications effectively. + +[[glossary]] +== Glossary + +[[microservices]] +Microservices:: An architectural style for building applications as a collection of small, independent services. Each service focuses on a specific business capability and communicates with other services through well-defined APIs. + +[[apis]] +APIs (Application Programming Interfaces):: A set of definitions and protocols that specify how software components interact with each other. + +[[cloud-native-development]] +Cloud-native development:: An approach to building and running applications that are specifically designed for the cloud environment. It involves using technologies and practices that leverage the benefits of cloud platforms, such as scalability, elasticity, and pay-as-you-go pricing. + +[[eclipse-foundation-working-group]] +Eclipse Foundation Working Group:: A collaborative group of industry leaders and Java community members who actively contribute to the of development of Eclipse projects like MicroProfile within the Eclipse Foundation framework. + +[[jakarta-ee]] +Jakarta EE:: Jakarta EE (formerly Java Platform, Enterprise Edition, or Java EE) is a set of specifications, extending Java Platform, Standard Edition, or Java SE with specifications for enterprise features such as web services, database persistence, asynchronous messaging and more. + +[[external-configuration]] +External Configuration:: A technique in application development where configuration data is separated from the application code, allowing the application's behavior to be adjusted without changing the code, especially useful in cloud-native and microservices architectures. + +[[health-checks]] +Health Checks:: Mechanisms used in microservices architectures to continuously check the status of an application or service to ensure it is functioning correctly and available to users. + +[[fault-tolerance]] +Fault Tolerance:: The ability of a system to continue operating in the event of the failure of some of its components. This feature is critical for maintaining high availability and reliability in microservices architectures. + +[[vendor-neutrality]] +Vendor Neutrality:: The principle of designing software products and standards not controlled by any single vendor, promoting user interoperability and choice. + +[[interoperability]] +Interoperability:: The ability of a software to exchange and make use of information across different platforms and services. + +[[json-p]] +JSON-P (JSON Processing):: A Jakarta EE (formerly Java EE) API that enables parsing, generating, transforming, and querying JSON data. It facilitates the processing of JSON data within the Java programming environment. Currently it is known as Jakarta JSON Processing. + +[[json-b]] +JSON-B (JSON Binding):: A Jakarta EE (formerly Java EE) API for binding Java objects to JSON messages and vice versa, streamlining the serialization and deserialization process. It allows custom mappings to handle complex conversion scenarios efficiently. Currently it is known as Jakarta JSON Binding. + +[[jax-rs]] +JAX-RS (Java API for RESTful Web Services):: A Jakarta EE API for creating web services according to the REST architectural pattern in Java, using annotations to simplify development. It enables the easy creation and management of resources via standard HTTP methods. It is currently known as Jakarta RESTful Web Services. + +[[cdi]] +CDI (Contexts and Dependency Injection):: A Jakarta EE API for enterprise-grade dependency injection, offering type-safe mechanisms, context lifecycle management, and a framework for decoupling application components. It enhances modularity and facilitates the development of loosely coupled, easily testable applications. + +[[boilerplate-code]] +Boilerplate Code:: A piece of code that must be included in many places with little or no alteration. + +[[lightweight-services]] +Lightweight Services:: Services designed to consume minimal computing resources, enhancing performance and efficiency, particularly relevant in a microservices architecture. + +[[resilient-services]] +Resilient Services:: Services built to recover quickly from failures and continue operating. It is critical for maintaining the reliability of microservices-based applications. + +[[observability]] +Observability:: The ability to measure the internal state of a system by examining its outputs, crucial for understanding the performance and behavior of microservices. + +[[monitoring]] +Monitoring:: The practice of tracking and logging the performance and status of applications and infrastructure, essential for maintaining system health in microservices environments. + +[[circuit-breaker]] +Circuit Breaker:: A fault tolerance mechanism that prevents a failure in one service from causing system-wide failure, by temporarily disabling failing services. + +[[bulkhead]] +Bulkhead:: A pattern that isolates failures in one part of a system from the others, ensuring that parts of an application can continue functioning despite issues elsewhere. + +[[retry]] +Retry:: A simple fault tolerance mechanism where an operation is attempted again if it fails initially, based on predefined criteria. + +[[timeout]] +Timeout:: A mechanism to limit the time waiting for a response from a service, helping to avoid resource deadlock situations in distributed systems. + +[[fallback]] +Fallback:: A fault tolerance mechanism that provides an alternative solution or response when a primary method fails. + +[[rbac]] +Role-Based Access Control (RBAC):: A method of restricting system access to authorized users based on their roles within an organization. + +[[kubernetes]] +Kubernetes:: An open-source platform for automating deployment, scaling, and operations of application containers across clusters of hosts. + +[[istio]] +Istio:: An open platform to connect, manage, and secure microservices, providing an easy way to create a network of deployed services with load balancing, service-to-service authentication, and monitoring. + +[[reactive-programming]] +Reactive Programming:: A programming paradigm oriented around data flows and the propagation of change, enabling the development of responsive and resilient systems. + +[[distributed-tracing]] +Distributed Tracing:: A method for monitoring applications, especially those built using a microservices architecture, by tracking the flow of requests and responses across services. + +[[lra]] +Long Running Actions (LRA):: A model for managing long-duration, distributed transactions across microservices without locking resources. + +[[reactive-streams]] +Reactive Streams:: An initiative to provide a standard for asynchronous stream processing with non-blocking back pressure. diff --git a/images/figure1-2.png b/images/figure1-2.png new file mode 100644 index 00000000..a9d1a072 Binary files /dev/null and b/images/figure1-2.png differ diff --git a/images/src/figure1-2 MP_Arch_Philosophy.drawio b/images/src/figure1-2 MP_Arch_Philosophy.drawio new file mode 100644 index 00000000..da9c95ee --- /dev/null +++ b/images/src/figure1-2 MP_Arch_Philosophy.drawio @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +