Cloud-Native Applications in Java

Book description

Highly available microservice-based web apps for Cloud with Java

About This Book

  • Take advantage of the simplicity of Spring to build a full-fledged application
  • Let your applications run faster while generating smaller cloud service bills
  • Integrate your application with various tools such as Docker and ElasticSearch and use specific tools in Azure and AWS

Who This Book Is For

Java developers who want to build secure, resilient, robust and scalable applications that are targeted for cloud based deployment, will find this book helpful. Some knowledge of Java, Spring, web programming and public cloud providers (AWS, Azure) should be sufficient to get you through the book.

What You Will Learn

  • See the benefits of the cloud environment when it comes to variability, provisioning, and tooling support
  • Understand the architecture patterns and considerations when developing on the cloud
  • Find out how to perform cloud-native techniques/patterns for request routing, RESTful service creation, Event Sourcing, and more
  • Create Docker containers for microservices and set up continuous integration using Jenkins
  • Monitor and troubleshoot an application deployed in the cloud environment
  • Explore tools such as Docker and Kubernetes for containerization and the ELK stack for log aggregation and visualization
  • Use AWS and Azure specific tools to design, develop, deploy, and manage applications
  • Migrate from monolithic architectures to a cloud native deployment

In Detail

Businesses today are evolving so rapidly that they are resorting to the elasticity of the cloud to provide a platform to build and deploy their highly scalable applications. This means developers now are faced with the challenge of building build applications that are native to the cloud. For this, they need to be aware of the environment, tools, and resources they're coding against.

If you're a Java developer who wants to build secure, resilient, robust, and scalable applications that are targeted for cloud-based deployment, this is the book for you. It will be your one stop guide to building cloud-native applications in Java Spring that are hosted in On-prem or cloud providers - AWS and Azure

The book begins by explaining the driving factors for cloud adoption and shows you how cloud deployment is different from regular application deployment on a standard data centre. You will learn about design patterns specific to applications running in the cloud and find out how you can build a microservice in Java Spring using REST APIs

You will then take a deep dive into the lifecycle of building, testing, and deploying applications with maximum automation to reduce the deployment cycle time. Gradually, you will move on to configuring the AWS and Azure platforms and working with their APIs to deploy your application. Finally, you'll take a look at API design concerns and their best practices. You'll also learn how to migrate an existing monolithic application into distributed cloud native applications.

By the end, you will understand how to build and monitor a scalable, resilient, and robust cloud native application that is always available and fault tolerant.

Style and approach

Filled with examples, this book will build you an entire cloud-native application through its course and will stop at each point and explain in depth the functioning and design considerations that will make a robust, highly available application

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Cloud-Native Applications in Java
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Foreword
  6. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  7. 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
  8. Introduction to Cloud-Native
    1. Why go cloud-native?
    2. What is cloud-native?
      1. Lift and shift
      2. Going native
      3. Going serverless
    3. Cloud-native and microservices
    4. The 12-factor app
      1. Microservices-enabling service ecosystem
    5. Microservice adoption
      1. Monolithic transformation
    6. Summary
  9. Writing Your First Cloud-Native Application
    1. Setting up your developer toolbox
      1. Getting an IDE
      2. Setting up internet connectivity
    2. Understanding the development life cycle
      1. Requirements/user stories
      2. Architecture
      3. Design
      4. Testing and development
      5. Building and deployment
    3. Selecting a framework
      1. Dropwizard
      2. Vert.x
      3. Spring Boot
    4. Writing a product service
      1. Creating a Maven project
      2. Writing a Spring Boot application class
      3. Writing service and domain objects
      4. Running the service
      5. Testing the service on the browser
      6. Creating a deployable
    5. Enabling cloud-native behaviors
      1. Externalizing configuration
      2. Metering your services
      3. Service registration and discovery
        1. Running a service registry
        2. Registering a product service
        3. Creating a product client
        4. Seeing the lookup in action
    6. Summary
  10. Designing Your Cloud-Native Application
    1. The trio – REST, HTTP, and JSON
    2. Rise and popularity of the APIs
    3. Role of API gateways
      1. Benefits of an API gateway
    4. Application decoupling
      1. Bounded context/domain-driven design
      2. Classification into up/downstream services
      3. Business events
    5. Microservice identification
      1. Differences between microservices and service-oriented architecture (SOA)
      2. Service granularity
    6. Microservice design guidelines
    7. Design and deployment patterns
      1. Design patterns
        1. Content aggregation patterns
          1. Aggregation by client
          2. API aggregation
          3. Microservice aggregation
          4. Database aggregation
        2. Coordination patterns
          1. Business process management (BPM)
          2. Composite services
          3. Why composite services?
          4. Capabilities for microservices coordination
        3. Coordination models
          1. Asynchronous parallel
          2. Asynchronous sequential
          3. Orchestration using request/response
          4. Collapsing the microservices
      2. Deployment patterns
        1. Multiple services per WAR file
          1. Benefits and trade-offs
          2. Suitability
        2. Service per WAR/EAR
          1. Benefits and trade-offs
          2. Suitability
        3. Service per process
          1. Benefits and trade-offs
          2. Suitability
        4. Service per Docker container
          1. Benefits and trade-offs
          2. Suitability
        5. Service per VM
          1. Benefits and trade-offs
          2. Suitability
        6. Service per host
          1. Benefits and trade-offs
          2. Suitability
      3. Release patterns
    8. Data architecture for microservices
      1. Command Query Responsibility Segregation (CQRS)
      2. Duplicating data
        1. Benefits
        2. Cons
      3. Fit for purpose
    9. The role of security
    10. Summary
  11. Extending Your Cloud-Native Application
    1. Implementing the get services
      1. Simple product table
        1. Running the service
        2. Limitations of traditional databases
      2. Caching
        1. Local cache
          1. Under the hood
          2. Limitations of a local cache
      3. Distributed cache
      4. Applying CQRS to separate data models and services
        1. Materialized views on a relational database
        2. Elasticsearch and a document database
          1. Why not use only a document database or Elasticsearch?
        3. Core product service on a document database
          1. Getting MongoDB ready with test data
          2. Creating the product service
        4. Splitting the services
        5. The product-search service
          1. Getting Elasticsearch ready with test data
          2. Creating the product-search service
    2. Data update services
      1. REST conventions
        1. Inserting a product
          1. Testing
        2. Updating a product
          1. Testing
        3. Deleting a product
          1. Testing
        4. Cache invalidation
      2. Validations and error messages
        1. Format validations
        2. Data validations
        3. Business validations
        4. Exceptions and error messages
      3. Data updates for CQRS
      4. Asynchronous messaging
        1. Starting ActiveMQ
          1. Creating a topic
      5. Golden source update
        1. Service methods
      6. Raising an event on data updates
        1. Using Spring JMSTemplate to send a message
      7. Query model update
        1. Insert, update, and delete methods
        2. Testing the CQRS update scenario end to end
    3. Summary
  12. Testing Cloud-Native Applications
    1. Writing test cases before development
      1. TDD
      2. BDD
    2. Testing patterns
      1. A/B testing
      2. Test doubles
        1. Test Stubs
        2. Mock objects
        3. Mock APIs
    3. Types of testing
      1. Unit testing
      2. Integration testing
      3. Load testing
      4. Regression testing
      5. Ensuring code review and coverage
    4. Testing the Product service
      1. BDD through Cucumber
        1. Why Cucumber?
        2. How does Cucumber work?
      2. Spring Boot Test
      3. Code coverage using JaCoCo
        1. Integrating JaCoCo
    5. Summary
  13. Cloud-Native Application Deployment
    1. Deployment models
      1. Virtualization
      2. PaaS
      3. Containers
        1. Docker
      4. Building Docker images
        1. Eureka server
        2. Product API
        3. Connecting to an external Postgres container
    2. Deployment patterns
      1. Blue-green deployment
      2. Canary deployment
      3. Dark release
      4. Applying CI/CD to automate
    3. Summary
  14. Cloud-Native Application Runtime
    1. The need for a runtime
    2. Implementing runtime reference architecture
      1. Service registry
      2. Configuration server
        1. The server part of the config server
        2. The config client
        3. Refreshing the properties
      3. The microservice frontend
        1. Netflix Zuul
        2. What happens behind the scenes
        3. Running them all at once
    3. Kubernetes – container orchestration
      1. Kubernetes architecture and services
      2. Minikube
      3. Running product service in Kubernetes
    4. Platform as a Service (PaaS)
      1. The case for PaaS
      2. Cloud Foundry
        1. The concept of org, account, and space
          1. The need for implementations of Cloud Foundry
      3. Pivotal Cloud Foundry (PCF)
        1. PCF components
        2. PCF Dev
          1. Installation
          2. Starting PCF Dev
        3. Creating the MySQL service on PCF
        4. Running the product service on PCF Dev
        5. Deploying to Cloud Foundry
    5. Summary
  15. Platform Deployment – AWS
    1. AWS platform
    2. AWS platform deployment options
      1. Deploying Spring Boot API to Beanstalk
        1. Deploying a runnable JAR
        2. Deploying Docker containers
      2. Deploying Spring Boot App to the Elastic Container Service
      3. Deploying to AWS Lambda
    3. Summary
  16. Platform Deployment – Azure
    1. Azure platform
    2. Azure platform deployment options
      1. Deploying Spring Boot API to Azure App Service
      2. Deploying Docker containers to Azure Container Service
      3. Deploying Spring Boot API to Azure Service Fabric
        1. Basic environment setup
        2. Packaging the product API application
        3. Starting the Service Fabric cluster
        4. Deploying the product API application to the Service Fabric cluster
          1. Connecting to the local cluster
          2. Connecting to the Service Fabric party cluster
      4. Azure cloud functions
        1. Environment setup
        2. Creating a new Java functions project
        3. Building and running the Java function
        4. Diving into code
    3. Summary
  17. As a Service Integration
    1. XaaS
    2. Key design concerns when building XaaS
    3. Integration with third-party APIs
    4. Summary
  18. API Design Best Practices
    1. API design concerns
      1. API resource identification
        1. System API
        2. Process API
        3. Channel API
      2. API design guidelines
        1. Naming and associations
        2. Base URLs for a resource
        3. Handling errors
        4. Versioning
        5. Pagination
        6. Attributes
        7. Data formats
        8. Client support for limited HTTP methods
        9. Authentication and authorization
        10. Endpoint redirection
        11. Content negotiation
        12. Secure
    2. API modeling
      1. Open API
      2. RESTful API Modeling Language (RAML)
    3. API gateway deployment models
    4. Summary
  19. Digital Transformation
    1. Application portfolio rationalization
      1. Portfolio analysis – business and technical parameters
        1. Retire
        2. Retain
        3. Consolidate
        4. Transform
    2. Monolithic application to distributed cloud-native application
      1. Transformation of a monolithic application to a distributed application
      2. Customer journey mapping to domain-driven design
      3. Defining the architecture runway
      4. Developer build
      5. Breaking the monolithic application
      6. Bringing it all together
    3. Building your own platform services (control versus delegation)
    4. Summary
  20. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Cloud-Native Applications in Java
  • Author(s): Ajay Mahajan, Munish Kumar Gupta, Shyam Sundar
  • Release date: February 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781787124349