Skip to content

Section 3: Step 04 — Persistent State #331

Description

@kdubois

Pattern: Custom ChatMemoryStore with JPA/Panache + quarkus-flow-jpa for durable workflows

Narrative: The gap from Step 03: restart the app and everything is lost — suspended workflows, conversations, all of it. A customer says "I'll think about it" and comes back the next day to find the system has forgotten everything. This step introduces a PostgreSQL database that makes two things persistent at once: conversation memory and workflow state.

What participants build:

  • Custom DatabaseChatMemoryStore implementation backed by a database (~30 lines)

Starter code provides:

  • Conversational TripChatAgent (@RegisterAiService with @MemoryId)
  • TripPlannerTools bridge to existing workflow
  • /trip/chat REST endpoint
  • ChatMessageEntity JPA entity
  • DatabaseChatMemoryProviderSupplier CDI wiring
  • quarkus-flow-jpa dependency (makes Quarkus Flow workflows from Step 03 durable — zero code changes to Flow)
  • Database setup via Dev Services (PostgreSQL)

Key learning: One database, two persistence wins. Conversations survive restarts via ChatMemoryStore. Quarkus Flow workflows survive restarts via quarkus-flow-jpa with autoRestore=true — the TripPlannerFlow from Step 03 is completely unchanged. The satisfying payoff: "remember how the workflow was lost when you restarted? Not anymore."

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions