Hands-On Enterprise Java Microservices with Eclipse MicroProfile

By Cesar Saavedra , Heiko W. Rupp , Jeff Mesnil and 3 more
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Introduction to Eclipse MicroProfile

About this book

Eclipse MicroProfile has gained momentum in the industry as a multi-vendor, interoperable, community-driven specification. It is a major disruptor that allows organizations with large investments in enterprise Java to move to microservices without spending a lot on retraining their workforce.

This book is based on MicroProfile 2.2, however, it will guide you in running your applications in MicroProfile 3.0. You'll start by understanding why microservices are important in the digital economy and how MicroProfile addresses the need for enterprise Java microservices. You'll learn about the subprojects that make up a MicroProfile, its value proposition to organizations and developers, and its processes and governance. As you advance, the book takes you through the capabilities and code examples of MicroProfile’s subprojects - Config, Fault Tolerance, Health Check, JWT Propagation, Metrics, and OpenTracing. Finally, you’ll be guided in developing a conference application using Eclipse MicroProfile, and explore possible scenarios of what’s next in MicroProfile with Jakarta EE.

By the end of this book, you'll have gained a clear understanding of Eclipse MicroProfile and its role in enterprise Java microservices.

Publication date:
August 2019
Publisher
Packt
Pages
256
ISBN
9781838643102

 

Introduction to Eclipse MicroProfile

Eclipse MicroProfile is a set of specifications for microservices written in the Java language. It is a project that is community-driven with many implementations in the market. The project, first announced in June 2016, continues to develop a set of common Application Programming Interfaces (APIs) for implementing Java microservices suitable for modern application development techniques, architectures, and environments. In this chapter, you will learn about the origin and importance of Eclipse MicroProfile. 

The following topics will be covered in this chapter:

  • Enterprise Java microservices
  • Forces that fuel the digital economy and the need for multi-speed IT
  • Introducing Eclipse MicroProfile
  • MicroProfile value proposition
 

Enterprise Java microservices

Application development no longer consists of using a single high-level programming language that runs on your favorite operating system. Nowadays, there are a myriad of languages, specifications, frameworks, proprietary and open source software and tools, underlying deployment infrastructures, and development methodologies that programmers need to learn to develop modern applications. Development at IT organizations has become polyglot, that is, multiple programming languages are used depending on the needs of specific projects. In this age of the cloud, containers, microservices, reactive programming, 12-factor applications, serverless, MINI services, polyglot environments, and so on, developers now have the option to choose the right tool for their task, making them more effective and productive.

With the recent move of Java EE to the Eclipse Foundation under the new name of Jakarta EE, MicroProfile will play a very important role in the future of Enterprise Java because of its synergy with Jakarta EE and the potential ways it can influence it.

The advent of the cloud and mobile, along with the acceleration of open and the Internet of Things (IoT) have brought about the digital economy. While this has opened up new markets, it has also imposed new demands on businesses and their IT organizations, which are now required to not only support and maintain traditional workloads but also deliver new applications at a faster pace.

Many technologies, languages, architectures, and frameworks have become popular within organizations in an attempt to tackle these new demands. One of these is microservices, specifically, Enterprise Java microservices, since Java is still one of the most popular languages in IT companies. But what is an Enterprise Java microservice?

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 API.
  • It must be enterprise-grade; that is, 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
 

Forces that fuel the digital economy

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:

Before the internet, organizations required brick-and-mortar stores or phone lines to conduct their businesses. The advent and accessibility of the internet created a critical category-formation time opportunity for organizations. Businesses started to use the internet mainly as a storefront or display in order to drive people to their brick-and-mortar stores. It was also used for advertising purposes.

Soon after this, businesses began adding the ability to purchase things online, and companies, such as Amazon, realized that they could capitalize on the economies-of-scale, product aggregation, consolidation, recommendation, and pricing optimization that an online store could provide. This was the very beginning of cloud and cloud-native applications. This is the first force that fueled the digital economy.

But what really accelerated the digital needs of businesses was the appearance of the second focus mobile devices, which connected even more people to the internet. More people now had a digital presence on the internet and businesses realized that these people were a new market that they could exploit. This new market required applications to scale to what people now call the internet scale. But paying for software licenses for this type of scalability was too expensive and prohibitive. This is where open source software, the third force that fueled the digital economy, came to the rescue. The power of the community accelerated the development of open source projects via crowdsourcing and open source collaboration. Anyone from anywhere in the globe could contribute to open source projects. Likewise, internet-scale companies, such as Amazon, Netflix, and Lyft, either use open source software or have created and contributed open source to the community.

Another benefit of open source software is its adoption of subscription-type support (for organizations that require external support for the software they run in production), which is significantly cheaper than software licensing. The growth of open source software fulfilled this need in the market, and companies such as Red Hat, purveyors of open source software, have succeeded in delivering enterprise-grade open source solutions.

As virtualization technologies matured and companies built and proved out internet-scale technologies and infrastructures, they realized that they could rent out these resources, such as compute and memory, to anybody. Consumption-based pricing made these resources even more accessible. Companies realized the value of saving costs, productivity, and speed-to-market of the cloud and started rushing to adopt this new model. Major companies such as Microsoft, Google, and Amazon all have cloud offerings.

IoT is the last and fourth force that is fueling the digital economy. Like the data generated by the digital presence of each person using the internet, IoT also generates large amounts of data that can be exploited to make sound business decisions. IoT demands internet-scale technologies and infrastructures that the cloud and big data technologies fulfill.

The convergence of these four different forces means that organizations have to adapt in the way they create and maintain business applications, thus affecting the speed at which they introduce innovation to their organizations. This is what is known as multi-speed IT, which we will discuss in more detail in the following section.

Multi-speed IT

Implementing and delivering applications as fast as possible is not a new requirement. In fact, since the invention of the first computer, increasing efficiency has always been in the minds of computer scientists. High-level programming languages, encapsulation, reusability, inheritance, event-driven design, SOA, microservices, machine learning, and AI, are all concepts that address the challenge of doing things faster. With each wave of new technology, the gearbox adds a new speed requirement to the evolution of how we develop and deliver software. The digital economy has added another high-speed gear to the gearbox.

Businesses need to adapt to the new demands of the digital economy. Not only do they have to create, run, and support traditional-style applications, but also applications that conform to the new demands of the digital economy. They have to support both waterfall and DevOps processes, hybrid cloud infrastructures, and SOA and microservice architectures.

This imposes many challenges on IT organizations, whose processes, people, and technology have all been geared toward the implementation, delivery, and maintenance of traditional-style applications. Many organizations have already embarked on, or are starting, their journey of digital transformation, which addresses the challenges of the digital economy. This journey includes changes in technologies, frameworks, languages, and processes for the development, delivery, integration, and maintenance of applications.

Whether you call it bimodal IT (https://www.gartner.com/it-glossary/bimodal) or a business technology strategy (https://go.forrester.com/wp-content/uploads/Forrester-False-Promise-of-Bimodal-IT.pdf), the fact is that IT needs to deliver faster than ever before on the needs of the business, for both existing and new applications. This means IT needs to also speed up the maintenance and delivery of existing applications while exclusively adopting Agile methodologies for new applications. This does not preclude, however, the need to still use different development processes, release cycles, and support timelines to handle existing applications versus new applications, which is effectively the multi-speed nature of IT.

 

Introducing Eclipse MicroProfile

Java EE has been an extremely successful platform. The Java Community Process (JCP) has been the steward of over 20 compatible implementations during its nearly 20-year history, resulting in a $4 billion industry. However, the management of Java EE by Oracle (unintentional or not) of Java EE (unintentional or not) stalled innovations, and while other standards have developed, the Java community worldwide and CIOs at all major enterprises desired an open standard for Java within their enterprise.

In its early stages, J2EE grew somewhat quickly from J2EE 1.2 up to J2EE 1.4, as the platform needed to address the immediate requirements of the enterprise. Beginning with Java EE 5 in May 2006, the pace began to slow down as the platform began to mature, and it was 3 years and 6 months between releases. After Java EE 7, which was released on June 12, 2013, there has been a long delay in its development. Java EE 8 was formally launched in September 2014 at JavaOne, where Oracle announced that it would be completed by JavaOne 2016. But then in June 2015, Oracle updated its release date to the first half of 2017. And again, at JavaOne 2016 (September), Oracle revised the Java EE 8 release date to the end of 2017. Java EE 8 was finally released on September 21, 2017, at JavaOne.

The following diagram shows the evolution timeline:

Java EE had been following the slower release cadence that a standards organization typically reflects. A standards-based release cadence by design does not address rapid innovations. And while this was occurring, the digital economy happened, which brought about the popularity and rising use of the cloud, containers, Agile methodologies, DevOps, continuous integration and continuous delivery, microservices, API management, and open source projects (Red Hat has been successful in delivering many of these solutions to the marketplace).

The slowdown in Java EE releases (and maturity) opened the door to competing technologies, such as Spring and Node.js, for example, which were able to fulfill the needs and requirements of digital businesses. In addition to this, many vendors, such as Red Hat and IBM, started innovating with Enterprise Java microservices based on a subset of Java EE and decided to collaborate in the open, potentially providing a wider effort upstream. This culminated in the announcement of Eclipse MicroProfile in June 2016 by many vendors, Java Champions, Java User Groups, and corporations.

Since MicroProfile was announced on June 27, 2016, at DevNation, a lot has happened. MicroProfile v 1.0 was released on September 19, 2016. Its implementation interoperability was demonstrated in November 2016 at Devoxx Belgium, where Red Hat, IBM, Tomitribe, and Payara demonstrated a unified web application (known as the Conference Application) with underlying microservices that had been developed separately by each vendor using MicroProfile. Additionally, MicroProfile became part of the Eclipse Foundation as an incubation project on December 14, 2016. New members, including SOUJava, Hazelcast, Fujitsu, Hammock, kumuluzEE, Oracle, Lightbend, and Microsoft, have joined the MicroProfile project. The complete list of members can be found at https://microprofile.io/.

Eclipse MicroProfile is a community-driven innovation project whose goal is to work on microservice patterns for Enterprise Java and to integrate applications with the infrastructures they run on (that is, a cloud environment) with patterns such as health checks and metrics. The focus of Eclipse MicroProfile is rapid collaborative innovation and this is why the project has a time-boxed release schedule, with each release including incremental updates or new features, and there is no guarantee of backward compatibility across releases. The Eclipse MicroProfile community is composed of individuals, vendors, and organizations.

Eclipse MicroProfile is not Java EE or a subset of Java EE. This confusion occurred because the first release of MicroProfile (before it became part of the Eclipse Foundation) was a collection of three Java EE APIs, namely, CDI, JSON-P, and JAX-RS. The MicroProfile community purposely made the first release of MicroProfile small because they wanted the community to decide the best path of evolution for the project.

The MicroProfile community took a no need to reinvent the wheel approach for the first release and chose three enterprise-grade, market- and production-proven APIs from Java EE to get started. In fact, MicroProfile utilizes some existing Java EE APIs and combines them with new APIs to create a platform for Java microservice architectures.

At the time of writing this book, Eclipse MicroProfile consists of 12 APIs (or sub-projects) under the project umbrella. Four of them come from Java EE APIs: CDI, JSON-P, JAX-RS, and JSON-B, and the remaining eight are MicroProfile-specific project. They are as follows:

  • Config
  • Fault Tolerance
  • JWT Propagation
  • Health Check
  • Metrics
  • Open API
  • Open Tracing
  • REST Client
  • CDI (a specification from Java EE)
  • JSON-P (a specification from Java EE)
  • JAX-RS (a specification from Java EE)
  • JSON-B (a specification from Java EE)

Here is a high-level explanation of the requirement that each of the aforementioned APIs fulfills:

  • MicroProfile Config addresses the need for changing the environmental parameters as an application or microservice moves across development, unit testing, integration/system testing, preproduction, and production environments, for example. MicroProfile Config makes it possible to set or modify configuration data from outside the application without repackaging it.
  • MicroProfile Fault Tolerance provides different strategies for when an application or microservice encounters a fault. MicroProfile Fault Tolerance provides specifications for constructs such as retries, circuit breakers, bulkheads, and timeouts, among others.
  • MicroProfile JWT Propagation handles security propagation across microservices.
  • MicroProfile Health Check fulfills the need to probe the state of a computing node from another machine, that is, a Kubernetes service controller. This specification examines cloud-infrastructure environments where the node state is tracked by automated processes.
  • MicroProfile Metrics delivers on the need to monitor the essential parameters of a running service, such as the system, application, business- and vendor-specific metrics in order to ensure its reliable operation.
  • MicroProfile Open API provides Java interfaces and programming models to natively produce OpenAPI v3 documents for RESTful services that can facilitate the management of microservice APIs.
  • MicroProfile Open Tracing defines the specification for equipping microservices to be traceable in a highly-distributed environment where messages can traverse different architectural tiers and services.
  • MicroProfile REST Client provides a type-safe approach to invoke RESTful services over HTTP in a consistent and easy-to-reuse fashion.
  • CDI (a specification from Java EE) handles all aspects of dependency injection.
  • JSON-P (a specification from Java EE) covers all aspects related to the processing of JSON objects.
  • JAX-RS (a specification from Java EE) handles all aspects related to RESTful communication.
  • JSON-B (a specification from Java EE) covers all aspects related from the object to JSON mapping.

It is worth mentioning that all the APIs (or sub-projects) created by the MicroProfile projects are not created in a vacuum. Although anybody can participate and is welcome in any sub-project, members of each sub-project are subject-matter experts with long and extensive expertise and experience. They apply their knowledge gained from the field, considering best practices, past lessons-learned, and other existing open source specifications and projects, to come up with the best approach for the corresponding MicroProfile sub-project.

Eclipse MicroProfile has been evolving rapidly and their versions have been progressively adding more functionality as follows:

  • Eclipse MicroProfile 1.1 included Config, which is a MicroProfile sub-project
  • Eclipse MicroProfile 1.2 included updates to Config as well as the new MicroProfile sub-projects: JWT Propagation, Metrics, Fault Tolerance, and Health Check.
  • Likewise, Eclipse MicroProfile 1.3 included additional brand new MicroProfile sub-projects: Open API, Open Tracing, and Rest Client.
  • MicroProfile 1.4 included updates to Config, JWT Propagation, Fault Tolerance, Open Tracing, and Rest Client.
  • In addition, MicroProfile 2.0 included the latest updates to CDI, JSON-P, JAX-RS, and the addition of JSON-B, all from Java EE 8. With these releases, Eclipse MicroProfile will offer the same level of functionality to be usable with either Java EE 7 or Java EE 8.
  • Eclipse MicroProfile 2.1 included updates to Open Tracing.
  • Eclipse MicroProfile 2.2 included updates to Fault Tolerance, Type Safe Rest Client, Open API, and Open Tracing.
  • Lastly, MicroProfile 3.0 included updates to Rest Client, and non-backward-compatible changes to Metrics and Health Check.

There are currently many implementations of Eclipse MicroProfile on the market. Eclipse MicroProfile is one of the tools that developers can leverage to solve problems and implement solutions with the enterprise capabilities needed to run workloads in production. In addition, developers familiar with Enterprise Java frameworks, such as Java EE, will find in MicroProfile a natural progression of Enterprise Java into the world of cloud-native application development.

 

MicroProfile value proposition

For customers who trust Enterprise Java to run their production workloads, Eclipse MicroProfile provides customers with a vendor-neutral specification for Enterprise Java microservices. Eclipse MicroProfile enables them to better fulfill the needs of the business via improved agility and scalability, faster time-to-market, higher development productivity, easier debugging and maintenance, and continuous integration and continuous deployment.

The benefits customers get by using Eclipse MicroProfile are the same benefits gained by using microservices. In general, according to Martin Fowler, a respected software developer, author, and speaker, microservices provide the following benefits (https://martinfowler.com/articles/microservice-trade-offs.html):

  • Strong module boundaries: Microservices reinforce modular structure, which is particularly important for larger teams.
  • Independent deployment: Simple services are easier to deploy and, since they are autonomous, they are less likely to cause system failures when things go wrong.
  • Technology diversity: With microservices, you can mix multiple languages, development frameworks, and data storage technologies.

In addition to the general benefits of microservices, Eclipse MicroProfile specifically provides the following:

  • The benefits of community collaboration: Eclipse MicroProfile is an open source project run by the community. No single vendor controls or determines the evolution and maturation of the specification.
  • Freedom of choice of implementation: Many vendors have implemented Eclipse MicroProfile as part of their software stacks and customers have the option to select whichever implementation is the most appropriate for their environment.
  • Faster evolution: Since Eclipse MicroProfile is an innovation project, new and improved functionality is delivered frequently in time-boxed releases. This allows developers and customers to have these at their fingertips and start leveraging updates in their projects sooner rather than later.
  • Based on decades of experience: Not only do the specification's subject-matter experts bring with them a vast wealth of experience, expertise, and knowledge, but Eclipse MicroProfile also leverages market-tested and production-proven capabilities in the Java EE APIs that it builds upon, offering maturity to developers.
  • Familiarity with Enterprise Java: Eclipse MicroProfile builds upon familiar Enterprise Java constructs, making it easy for Enterprise Java developers to adopt.
  • No retraining needed: Your existing Enterprise Java developers will find Eclipse MicroProfile to be a natural progression of their expertise. There is little to no learning curve. They will be able to leverage their skills.
  • Interoperability: The different MicroProfile implementations are interoperable, with each one providing users with the freedom to select one, or combine many, MicroProfile implementations in an application.
  • Multiple ways to use the APIs: Eclipse MicroProfile APIs provide easy-to-use interfaces, such as CDI-based, programmatic, command-line, and file-based (configuration-based) interfaces.
  • A thorough set of artifacts: Each API includes a Test Compatibility Kit (TCK), Javadoc, PDF document for download, API Maven artifact coordinates, Git tags, and downloads (specification and source code).
  • Many other benefits that are particular to each API. These are discussed in each Eclipse MicroProfile sub-project section throughout this book.
 

Summary

In this chapter, we have discussed the new trends in software development, consisting of polyglot deployments using new approaches, such as microservices, containers, mobile, and Internet-of-Things (IoT) running on-premises and in the cloud; and in hybrid or multi-cloud environments. These trends required the evolution of Enterprise Java in the microservices world, which is what MicroProfile addresses. The four forces that fuel the digital economy, namely, cloud, mobile, IoT, and open source, have contributed to the need for organizations to have multi-speed IT departments, which are necessary to maintain and evolve their existing applications as well as to take advantage of new technological trends to develop new applications that can help them to remain competitive.

Eclipse MicroProfile, a vendor-neutral specification founded by the community for the community, is one of these new trends for Enterprise Java microservices. Lastly, Eclipse MicroProfile brings rapid innovation to Enterprise Java by its development agility based on lessons learned and decades of experience by the subject-matter experts who participate in its sub-teams. This chapter has helped you to understand what an Enterprise Java microservice is and what the rest of the book will cover.

In the next chapter, we will go over the governance, that is, the lightweight process that anybody in the community can follow to contribute to the Eclipse MicroProfile project. Additionally, we will examine the contributions made to the project, namely, the Eclipse MicroProfile Starter, which is a sample source code generator contribution.

 

Questions

  1. What is an Enterprise Java microservice?
  2. What are the four forces that fuel the digital economy?
  3. Why are IT organizations having to develop and maintain applications at different speeds? What is multi-speed IT?
  4. Why are Java and Java EE still important to organizations?
  5. What was one of the key reasons that caused MicroProfile to come into existence?
  6. What are the APIs/specifications that are part of the MicroProfile umbrella/platform release?
  7. What release of MicroProfile introduced the first revolutionary changes?
  8. Why is MicroProfile valuable to organizations?

About the Authors

  • Cesar Saavedra

    Cesar Saavedra has been working in the IT industry since 1990 and holds a Master of Science degree in Computer Science and a Master of Business Administration. He has worked as a developer, consultant, technical seller, and technical marketer throughout his career. He currently does technical product marketing for Red Hat JBoss Enterprise Application Platform (EAP), Eclipse MicroProfile, OpenJDK, Quarkus and Jakarta EE. He also manages the technical marketing for the runtimes, integration, BPM and rules management portfolio, and works closely with engineering and product management on thought leadership. Cesar has authored white papers, eBooks, and blogposts, and has been a conference and webinar speaker presenting to customers and partners.

    Browse publications by this author
  • Heiko W. Rupp

    Heiko W. Rupp is an open source enthusiast working for more than a decade at Red Hat in the area of middleware monitoring and management. In this role he has been project lead of the RHQ and Hawkular monitoring systems and has also been contributing to various other projects like Kiali. Currently he helps defining the next way of Java Microservices with his work on Eclipse MicroProfile. As such he is the spec lead of the Eclipse MicroProfile Metrics effort and also contributing to other specifications. Heiko has written the first German book about JBossAS and one of the first German books on EJB3. He lives with his family in Stuttgart, Germany.

    Browse publications by this author
  • Jeff Mesnil

    Jeff Mesnil is employed by Red Hat as a Senior Software Engineer and currently, works for JBoss, Red Hat's middleware division, on the WildFly and JBoss EAP application servers. He is a member of the core team in charge of developing the internals of the application servers and lead its messaging subsystem (which provides the JMS API). Previously, he contributed to the HornetQ messaging broker that was integrated into WildFly and EAP. He is a proponent of Open Source development and all the code he writes either professionally or privately is available under Open Source licenses, these days, it is mostly hosted on GitHub. He has a keen interest on messaging systems and wrote several Open Source libraries related to messaging.

    Browse publications by this author
  • Pavol Loffay

    Pavol Loffay is Senior Software Engineer at Red Hat. Pavol is working on observability tools for microservice architectures. He is mostly involved in the tracing domain, where he is an active committer on the Jaeger and OpenTracing projects. He is also a member of the OpenTracing Specification Council (OTSC) and a lead for the MicroProfile-OpenTracing specification. He has authored many blog posts and presented at several conferences. In his free time, Pavol likes to climb mountains and ski steep slopes in the Alps.

    Browse publications by this author
  • Antoine Sabot-Durand

    Antoine Sabot-Durand is a Java Champion who works for Red Hat where he leads the Java EE, now Jakarta EE CDI spec. He is also involved in various projects linked to the CDI ecosystem, MicroProfile, and Jakarta EE. He is also Member of Devoxx France committee. He lives in France with his wife and 3 kids.

    Browse publications by this author
  • Scott Stark

    Scott Stark started in chemical engineering, got steered into parallel computers as part of his Ph.D. work, and then made software his career, starting with a stint in finance/wall street. He then got into open source with the fledgling JBoss company, working on the application server and Java EE. He has worked with microkernel efforts, IoT efforts, standards, Jakarta EE, Eclipse MicroProfile and Quarkus. He lives in the Pacific Northwest with his wife.

    Browse publications by this author
Book Title
Access this book, plus 7,500 other titles for FREE
Access now