O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hands-On Cloud Development with WildFly

Book Description

Create microservices using Java EE technologies with WildFly Swarm,deploy them in the OpenShift cloud, make them resilient to network failures using Hystrix, configure continuous integration using Jenkins, and security using Keycloak.

About This Book
  • Create functional microservices with WildFly Swarm
  • Use OpenShift to deploy your microservices in the cloud
  • Make your application production-ready using Jenkins, Hystrix, and Keycloak
Who This Book Is For

If you're an experienced developer familiar with Java EE technologies and would like to learn how you can use those technologies in the cloud with WildFly and OpenShift, then this book is for you.

What You Will Learn
  • Utilize Java EE technology to develop modern cloud-enabled applications
  • Easily create microservices with WildFly Swarm using proven Java EE technologies
  • See the benefits of OpenShift – easy deployment of your services, out of the box scalability and healing, and integration with Continuous Integration tools
  • Integrate the sample application with Jenkins’ Continuous Integration server
  • Utilize Netflix OSS to connect your services and provide resilience to your application
  • Provide security to your application using Keycloak
In Detail

The book starts by introducing you to WildFly Swarm—a tool that allows you to create runnable microservices from Java EE components. You’ll learn the basics of Swarm operation—creating a microservice containing only the parts of enterprise runtime needed in a specific case. Later, you’ll learn how to configure and test those services.

In order to deploy our services in the cloud, we’ll use OpenShift. You’ll get to know basic information on its architecture, features, and relationship to Docker and Kubernetes. Later, you’ll learn how to deploy and configure your services to run in the OpenShift cloud.

In the last part of the book, you’ll see how to make your application production-ready. You’ll find out how to configure continuous integration for your services using Jenkins, make your application resistant to network failures using Hystrix, and how to secure them using Keycloak.

By the end of the book, you’ll have a fully functional example application and will have practical knowledge of Java EE cloud development that can be used as a reference in your other projects.

Style and approach

This example-based tutorial guides you step by step through creating an application based on well-known Java EE technologies (JAX-RS, CDI, JPA, and JSF) and modern architectural patterns.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Cloud Development with WildFly
  3. PacktPub.com
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Java EE and Modern Architectural Methodologies
    1. Java EE
      1. Java Community Process
      2. The basic architecture of Java EE applications
      3. The scope of the Java EE standard
      4. Implementation of Java EE standard
    2. Current development trends
      1. Cloud computing
      2. Microservices
        1. Advantages of implementing microservices
        2. Challenges of implementing microservices
        3. When to adopt the microservice architecture
        4. Microservices and the cloud
      3. Java EE microservices
    3. The goal of the book
      1. The pet store application
      2. The technologies used
    4. Summary
    5. Further reading
  7. Getting Familiar with WildFly Swarm
    1. Introducing WildFly
      1. Performance
      2. Extensible nature
      3. Deployment model
    2. Meet WildFly Swarm
      1. Java EE application
      2. Adapting to WildFly Swarm
      3. Does it really work?
      4. What has just happened here?
    3. Summary
    4. Further reading
  8. Right-Sizing Your Services
    1. Catalog service
      1. Draft version
    2. Fractions
    3. Fraction detection
      1. Fraction detection mode
    4. Thin and hollow JARs
      1. Using hollow JARs
      2. Using thin JARs
    5. Summary
  9. Tuning the Configuration of Your Services
    1. Modifying Swarm configuration
      1. System properties
      2. Implementing your own main class
      3. The Swarm class
        1. Providing the configuration
        2. Using your own main along with properties
      4. Java API
    2. Modifying your archive
      1. The ShrinkWrap API
      2. Obtaining the default archive
      3. Swarm ShrinkWrap extensions
        1. JARArchive
        2. WARArchive
        3. JAXRSArchive
      4.  XML configuration
      5. YAML configuration
        1. Project stages
      6. YAML database configuration
    3. Mixing the configurations
    4. Summary
    5. Further reading
  10. Testing Your Services with Arquillian
    1. Introducing Arquillian
    2. Testing Swarm microservices with Arquillian
      1. The default deployment
      2. Swarm configuration
      3. Testing from a standalone client
    3. Summary
    4. Further reading
  11. Deploying Applications on the Cloud with OpenShift
    1. Cloud computing
      1. The cloud infrastructure deployment model
        1. The public cloud
        2. The private cloud
        3. The hybrid cloud
      2. The service model
        1. Infrastructure as a Service
        2. Platform as a Service
        3. Software as a Service
    2. The OpenShift architecture
    3. Containerization
      1. Virtualization
      2. Containers
      3. Kernel isolation tools
        1. Namespaces
        2. cgroups
      4. The Docker implementation of containers
        1. Images and containers
        2. Docker registries
        3. Docker wrap-up
      5. Orchestrating Docker
      6. Kubernetes
        1. Nodes and master services
        2. Volumes
        3. Pods
        4. Deployments
          1. Services
        5. Labels
        6. Benefits
    4. OpenShift
      1. The build infrastructure
      2. Management of projects and users
      3. Minishift
        1. Installation
        2. Starting the cluster
      4. Web console
        1. YAML notation
      5. CLI
    5. Catalog-service on the OpenShift example
    6. Summary
    7. Further reading
  12. Configuring Storage for Your Applications
    1. OpenShift storage concepts
      1. Volumes
        1. Empty directory
        2. Host path
        3. Remote filesystems
        4. PersistentVolume and PersistentVolumeClaims
    2. The catalog-service with database
      1. Configuring PostgreSQL database
      2. Inspecting the volumes
      3. Updating catalog-service
    3. Summary
  13. Scaling and Connecting Your Services
    1. Deployments
      1. Learning the basics of ReplicationController
    2. Load balancing
    3. Service discovery
      1. New services
        1. The pricing service
      2. The customer gateway service
      3. Environment variables
      4. DNS discovery
    4. Summary
  14. Configuring Continuous Integration Using Jenkins
    1. Learning OpenShift builds
    2. Learning about the source-to-image build
      1. Configuring environment variables
      2. The whole source-to-image algorithm
      3. Source-to-image summary
      4. The developer view
    3. Pipeline build
      1. Continuous integration
      2. Continuous deployment
      3. Deployment pipeline
    4. Configuring Continuous Deployment in OpenShift environments
      1. Introducing Jenkins
        1. Our first pipeline
      2. Pipeline syntax language
        1. Core pipeline elements
        2. Standard Maven operation
        3. OpenShift Pipeline Plugin
    5. Summary
    6. Further reading
  15. Providing Security Using Keycloak
    1. Token-based security
      1. Rationale
      2. A basic architecture
      3. OpenID Connect
        1. Authentication code flow
    2. Introducing Keycloak
      1. Cart-service
      2. Installing Keycloak
      3. Creating realm
      4. Create a client
      5. Users and roles
      6. Scopes
      7. Cart service
      8. WildFly Swarm Keycloak adapter
    3. SSL configuration
      1. Secured cloud
      2. Unsecured cloud
    4. Summary
    5. Further reading
  16. Adding Resilience Using Hystrix
    1. Unreliable network
      1. Dependent services
    2. The circuit breaker pattern
      1. The Hystrix circuit breaker
      2. Bulkheading
      3. Fallbacks
      4. The whole algorithm
    3. Using Hystrix
    4. Summary
    5. Further reading
  17. Future Direction
    1. No more standards?
    2. Eclipse MicroProfile
    3. Jakarta EE
    4. Summary
    5. Further reading
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think