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

Cloud Native Java

Book Description

What separates the traditional enterprise from the likes of Amazon, Netflix, and Etsy? Those companies have refined the art of cloud native development to maintain their competitive edge and stay well ahead of the competition. This practical guide shows Java/JVM developers how to build better software, faster, using Spring Boot, Spring Cloud, and Cloud Foundry.

Many organizations have already waded into cloud computing, test-driven development, microservices, and continuous integration and delivery. Authors Josh Long and Kenny Bastani fully immerse you in the tools and methodologies that will help you transform your legacy application into one that is genuinely cloud native.

In four sections, this book takes you through:

  • The Basics: learn the motivations behind cloud native thinking; configure and test a Spring Boot application; and move your legacy application to the cloud
  • Web Services: build HTTP and RESTful services with Spring; route requests in your distributed system; and build edge services closer to the data
  • Data Integration: manage your data with Spring Data, and integrate distributed services with Spring’s support for event-driven, messaging-centric architectures
  • Production: make your system observable; use service brokers to connect stateful services; and understand the big ideas behind continuous delivery

Table of Contents

  1. Foreword (James Watters)
  2. Foreword (Rod Johnson)
  3. Preface
    1. Who Should Read This Book
    2. Why We Wrote This Book
    3. Navigating This Book
    4. Online Resources
    5. Conventions Used in This Book
    6. Using Code Examples
    7. O’Reilly Safari
    8. How to Contact Us
    9. Acknowledgments
      1. Josh Long
      2. Kenny Bastani
  4. I. Basics
    1. 1. The Cloud Native Application
      1. Amazon’s Story
      2. The Promise of a Platform
      3. The Patterns
      4. Scalability
      5. Reliability
      6. Agility
      7. Netflix’s Story
        1. Microservices
        2. Splitting the Monolith
        3. Netflix OSS
        4. Cloud Native Java
      8. The Twelve Factors
        1. Codebase
        2. Dependencies
        3. Config
        4. Backing Services
        5. Build, Release, Run
        6. Processes
        7. Port Bindings
        8. Concurrency
        9. Disposability
        10. Dev/Prod Parity
        11. Logs
        12. Admin Processes
      9. Summary
    2. 2. Bootcamp: Introducing Spring Boot and Cloud Foundry
      1. What Is Spring Boot?
      2. Getting Started with the Spring Initializr
      3. Getting Started with the Spring Tool Suite
        1. Installing Spring Tool Suite (STS)
        2. Creating a New Project with the Spring Initializr
      4. The Spring Guides
        1. Following the Guides in STS
      5. Configuration
      6. Cloud Foundry
      7. Summary
    3. 3. Twelve-Factor Application Style Configuration
      1. The Confusing Conflation of “Configuration”
      2. Support in Spring Framework
        1. The PropertyPlaceholderConfigurer
        2. The Environment Abstraction and @Value
        3. Profiles
      3. Bootiful Configuration
      4. Centralized, Journaled Configuration with the Spring Cloud Configuration Server
        1. The Spring Cloud Config Server
        2. Spring Cloud Config Clients
        3. Security
      5. Refreshable Configuration
      6. Summary
    4. 4. Testing
      1. The Makeup of a Test
      2. Testing in Spring Boot
      3. Integration Testing
        1. Test Slices
        2. Mocking in Tests
        3. Working with the Servlet Container in @SpringBootTest
        4. Slices
      4. End-to-End Testing
        1. Testing Distributed Systems
        2. Consumer-Driven Contract Testing
        3. Spring Cloud Contract
      5. Summary
    5. 5. The Forklifted Application
      1. The Contract
      2. Migrating Application Environments
        1. The Out-of-the-Box Buildpacks
        2. Custom(ized) Buildpacks
        3. Containerized Applications
      3. Soft-Touch Refactoring to Get Your Application into the Cloud
        1. Talking to Backing Services
        2. Achieving Service Parity with Spring
      4. Summary
  5. II. Web Services
    1. 6. REST APIs
      1. Leonard Richardson’s Maturity Model
      2. Simple REST APIs with Spring MVC
      3. Content Negotiation
        1. Reading and Writing Binary Data
        2. Google Protocol Buffers
      4. Error Handling
      5. Hypermedia
        1. Media Type and Schema
      6. API Versioning
      7. Documenting REST APIs
      8. The Client Side
        1. REST Clients for Ad Hoc Exploration and Interaction
        2. The RestTemplate
      9. Summary
    2. 7. Routing
      1. The DiscoveryClient Abstraction
      2. Cloud Foundry Route Services
      3. Summary
    3. 8. Edge Services
      1. The Greetings Service
      2. A Simple Edge Service
      3. Netflix Feign
      4. Filtering and Proxying with Netflix Zuul
        1. A Custom Zuul Filter
      5. Security on the Edge
      6. OAuth
        1. Service-Side Applications
        2. HTML5 and JavaScript Single-Page Applications
        3. Applications Without Users
        4. Trusted Clients
      7. Spring Security
      8. Spring Cloud Security
        1. A Spring Security OAuth Authorization Server
        2. Securing the Greetings Resource Server
        3. Build an OAuth-Secured Single-Page Application
        4. Summary
  6. III. Data Integration
    1. 9. Managing Data
      1. Modeling Data
        1. Relational Database Management Systems (RDBMS)
        2. NoSQL
      2. Spring Data
        1. Structure of a Spring Data Application
        2. Domain Class
        3. Repositories
        4. Organizing Java Packages for Domain Data
      3. Getting Started with RDBMS Data Access on JDBC
      4. Spring’s JDBC Support
      5. Spring Data Examples
      6. Spring Data JPA
        1. Account Service
        2. Integration Tests
      7. Spring Data MongoDB
        1. Order Service
        2. Integration Tests
      8. Spring Data Neo4j
        1. Inventory Service
        2. Integration Tests
      9. Spring Data Redis
        1. Caching
      10. Summary
    2. 10. Messaging
      1. Event-Driven Architectures with Spring Integration
        1. Messaging Endpoints
        2. From Simple Components, Complex Systems
      2. Message Brokers, Bridges, the Competing Consumer Pattern, and Event Sourcing
        1. Publish-Subscribe Destination
        2. Point-to-Point Destination
      3. Spring Cloud Stream
        1. A Stream Producer
        2. A Stream Consumer
      4. Summary
    3. 11. Batch Processes and Tasks
      1. Batch Workloads
      2. Spring Batch
        1. Our First Batch Job
      3. Scheduling
      4. Remote Partitioning a Spring Batch Job with Messaging
      5. Task Management
      6. Process-Centric Integration with Workflow
      7. Distribution with Messaging
      8. Summary
    4. 12. Data Integration
      1. Distributed Transactions
      2. Isolating Failures and Graceful Degradation
      3. The Saga Pattern
      4. CQRS (Command Query Responsibility Segregation)
        1. The Complaints API
        2. The Complaint Statistics API
      5. Spring Cloud Data Flow
        1. Streams
        2. Tasks
        3. The REST API
        4. Meet the Data Flow Clients
      6. Summary
  7. IV. Production
    1. 13. The Observable System
      1. You Build It, You Run It
      2. Murder Mystery Microservices
      3. Twelve-Factor Operations
      4. The New Deal
      5. Observability
      6. Push Versus Pull Observability and Resolution
      7. Capturing an Application’s Present Status with Spring Boot Actuator
      8. Metrics
      9. Identifying Your Service with the /info Endpoint
      10. Health Checks
      11. Audit Events
      12. Application Logging
        1. Specifying Log Output
        2. Specifying Log Levels
      13. Distributed Tracing
        1. Finding Clues with Spring Cloud Sleuth
        2. How Much Data Is Enough?
        3. OpenZipkin: A Picture Is Worth a Thousand Traces
        4. Tracing Other Platforms and Technologies
      14. Dashboards
        1. Monitoring Downstream Services with the Hystrix Dashboard
        2. Codecentric’s Spring Boot Admin
        3. Ordina Microservices Dashboard
        4. Pivotal Cloud Foundry’s AppsManager
      15. Remediation
      16. Summary
    2. 14. Service Brokers
      1. The Life of a Backing Service
      2. The View from the Platform
      3. Implementing a Service Broker with Spring Cloud Cloud Foundry Service Broker
        1. A Simple Amazon S3 Service Broker
        2. The Service Catalog
        3. Managing Service Instances
        4. Service Bindings
        5. Securing the Service Broker
      4. Deployment
        1. Releasing with BOSH
        2. Releasing with Cloud Foundry
      5. Registering the Amazon S3 Service Broker
      6. Creating Amazon S3 Service Instances
        1. Consuming Service Instances
      7. An S3 Client Application
      8. Seeing It All Come Together
      9. Summary
    3. 15. Continuous Delivery
      1. Beyond Continuous Integration
        1. John Allspaw at Flickr and then Etsy
        2. Adrian Cockroft at Netflix
        3. Continuous Delivery at Amazon
      2. The Pipeline
      3. Testing
      4. Continuous Delivery for Microservices
      5. Tools
      6. Concourse
        1. Containers
      7. Continuously Delivering Microservices
        1. Installing Concourse
        2. Basic Pipeline Design
        3. Continuous Integration
      8. Consumer-Driven Contract Testing
        1. User Microservice Pipeline
      9. Data
      10. To Production!
  8. V. Appendix
    1. A. Using Spring Boot with Java EE
      1. Compatibility and Stability
      2. Dependency Injection with JSR 330 (and JSR 250)
      3. Using Servlet APIs in a Spring Boot Application
      4. Building REST APIs with JAX-RS (Jersey)
      5. JTA and XA Transaction Management
        1. Resource-Local Transactions with Spring’s PlatformTransactionManager
        2. Global Transactions with the Java Transaction API (JTA)
      6. Deployment in a Java EE Environment
      7. Summary
  9. Index