Leanpub Header

Skip to main content

Crash Free Spring Pet Clinic

A Hands-On Tour of Temporal

Each Temporal concept is introduced organically and in the context of the business needs of the Spring PetClinic — because a growing veterinary clinic keeps handing Temporal a reason to extend it further — in code you can run.

Minimum price

$25.00

$25.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

A hands-on tour of Temporal — the platform for durable execution — taught

by taking the familiar Spring PetClinic application and growing it, one feature

at a time, until it exercises the full surface of durable execution: Workflows

and Activities, Signals, Queries, and Updates, durable timers, the Saga pattern,

child Workflows, continue-as-new, Schedules, versioning, heartbeats and can-

cellation, Search Attributes, testing, and observability.

Share this book

Categories

Author

About the Author

Geertjan

I’m a Java Champion, founder of Friends of OpenJDK (Foojay.io), Apache Member and Apache NetBeans PMC Chair, an open source enthusiast, and now an independent author, contractor, and consultant, after 25 years of fulltime work at Sun Microsystems, Oracle, and Azul.

Contents

Table of Contents

Crash-Free Spring PetClinic

  1. Learning Temporal and Durable Execution by Growing an App You Already Know

Chapter 1: Introduction

  1. What Temporal is, and the problem it solves
  2. Why PetClinic is the perfect teacher
  3. How the book works
  4. The arc of the book
  5. What you need
  6. How to read it

Chapter 2: Your First Workflow and Activity

  1. What a Workflow, an Activity, and a Worker are
  2. Step 1: Start a local Temporal server
  3. Step 2: Add the Temporal Spring Boot starter
  4. Step 3: Point the app at Temporal and enable a Worker
  5. Step 4: Define the Activity
  6. Step 5: Define the Workflow
  7. Step 6: Start the Workflow from the controller
  8. Step 7: Build and run
  9. Step 8: Verify the Worker is polling
  10. Step 9: Book a visit and watch it run
  11. What you gained

Chapter 3: Orchestrating Multiple Activities

  1. The goal
  2. Step 1: Add the second Activity to the interface
  3. Step 2: Implement it
  4. Step 3: Call it from the Workflow with its own retry policy
  5. Step 4: Rebuild, restart, and book a visit
  6. Step 5: Confirm both Activities in the event history
  7. What this bought you
  8. Where to go next

Chapter 4: Checking a Pet In with Signals

  1. What a Signal is
  2. Step 1: Add a Signal method to the Workflow interface
  3. Step 2: Wait for the Signal in the implementation
  4. Step 3: Send the Signal from the controller
  5. Step 4: From the CLI
  6. What to watch in the Web UI
  7. What you gained

Chapter 5: Asking a Booking Its Status with Queries

  1. What a Query is
  2. Step 1: Add a Query method to the interface
  3. Step 2: Expose state from the implementation
  4. Step 3: Query from the controller
  5. Step 4: From the CLI
  6. A caveat worth internalizing
  7. What you gained

Chapter 6: Approving a Change with Updates

  1. What an Update is
  2. Step 1: Declare the Update and its validator
  3. Step 2: Implement the validator and the handler
  4. Step 3: Call the Update from the controller
  5. Step 4: From the CLI
  6. Signals vs. Queries vs. Updates
  7. What you gained

Chapter 7: Sending Reminders with Durable Timers

  1. What a durable Timer is
  2. Step 1: Compute the delay and sleep
  3. Step 2: Add the reminder Activity
  4. Step 3: Combine timers with Signals
  5. Watching it in the Web UI
  6. The catch worth stating plainly
  7. What you gained

Chapter 8: Handling Failure the Temporal Way

  1. The default, and why you tune it
  2. Step 1: Mark a failure non-retryable at the source
  3. Step 2: Exclude failure types in the retry policy
  4. Step 3: React to failure in the Workflow
  5. Timeouts are failures too
  6. Debugging a failure in the Web UI
  7. What you gained

Chapter 9: Billing a Visit with the Saga Pattern

  1. What the Saga pattern is
  2. Step 1: Model the forward steps and their compensations as Activities
  3. Step 2: Drive the Saga from the Workflow
  4. Step 3: Compensations should be idempotent
  5. Step 4: Watch a rollback happen
  6. Why this beats a hand-rolled rollback
  7. What you gained

Chapter 10: Booking Many Pets with Child Workflows

  1. What a Child Workflow is
  2. Step 1: The child is just a Workflow
  3. Step 2: The parent starts one child per pet
  4. Step 3: Parent and child lifecycles — ParentClosePolicy
  5. Step 4: Getting results back
  6. Watching it in the Web UI
  7. What you gained

Chapter 11: Never-Ending Reminders with Continue-As-New

  1. What continue-as-new is
  2. Step 1: Do a bounded chunk of work, then continue
  3. Step 2: When to continue
  4. Step 3: Signals and continue-as-new — drain first
  5. Watching it in the Web UI
  6. What you gained

Chapter 12: Recurring Checkups with Schedules and Cron

  1. What a Schedule is
  2. Step 1: The Workflow being scheduled is ordinary
  3. Step 2: Create a Schedule with the client
  4. Step 3: Operating a Schedule
  5. Step 4: Overlap policy
  6. Watching it in the Web UI
  7. Schedule vs. continue-as-new
  8. What you gained

Chapter 13: Evolving Workflows Safely with Versioning

  1. Why replay makes this hard
  2. Approach 1: Workflow.getVersion for in-place changes
  3. Approach 2: Worker Versioning for whole-Workflow changes
  4. What is safe to change without versioning
  5. Testing for non-determinism before you deploy
  6. Watching a non-determinism error
  7. What you gained

Chapter 14: Long-Running Work with Heartbeats and Cancellation

  1. Why a long Activity needs a heartbeat
  2. Step 1: Heartbeat from a long Activity
  3. Step 2: Configure the heartbeat timeout
  4. Step 3: Cancellation — stopping work that is no longer wanted
  5. Step 4: Cancelling from the Workflow or client
  6. Watching it in the Web UI
  7. What you gained

Chapter 15: Finding Visits with Search Attributes

  1. What Search Attributes are
  2. Step 1: Register the custom attributes
  3. Step 2: Set attributes when starting the Workflow
  4. Step 3: Update an attribute as the Workflow progresses
  5. Step 4: Search
  6. Built-in attributes you already have
  7. A note on the dev server
  8. What you gained

Chapter 16: Testing Workflows with Confidence

  1. The test framework in one breath
  2. Step 1: Test a Workflow with mocked Activities
  3. Step 2: Test a durable timer without waiting
  4. Step 3: Test Signals, Queries, and Updates
  5. Step 4: Replay testing — the guard against non-determinism
  6. Step 5: Activities can be unit-tested plainly
  7. What you gained

Chapter 17: Seeing Inside Workflows with OpenTelemetry

  1. Why this is the right closing chapter
  2. How Temporal traces work
  3. Step 1: Add the OpenTelemetry dependencies
  4. Step 2: Build the interceptor and register it
  5. Step 3: Point OTLP at a backend
  6. Step 4: Read a booking as a trace
  7. What OTel adds over the Web UI
  8. What you gained, and where the book leaves you

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub