What You’ll Build
You’ll create a simple notification workflow that:- Sends an email notification
- Waits for confirmation
- Logs the result
Define Your Service
Create a service interface and implementation. Services contain the actual business logic.
NotificationService.kt
Services are where you implement your actual business logic - API calls, database operations, external service integrations, etc. Infinitic handles execution, retries, and error handling.
Create a Workflow
Define a workflow interface and implementation. Workflows orchestrate services and define your business process.
NotificationWorkflow.kt
Workflows define the orchestration logic. They are deterministic and can be replayed, which means they shouldn’t contain any non-deterministic operations like
Random() or direct API calls. Use services for those operations instead.Configure Infinitic
Create a configuration file for your worker and client. This example uses in-memory transport for quick local development.
infinitic.yml
Start a Worker
Workers execute your services and workflows. Create a worker application:Run your worker:
Worker.kt
Workers are long-running processes that consume messages from Pulsar, execute tasks, and produce responses. You can run multiple workers for horizontal scaling.
What’s Happening?
When you execute the workflow:- The client sends a message to start the workflow
- A workflow worker picks up the message and begins executing
NotificationWorkflowImpl.process() - When the workflow calls
notificationService.sendEmail(), it dispatches a service task - A service worker executes
NotificationServiceImpl.sendEmail() - The result flows back to the workflow, which completes and returns to the client
Next Steps
Learn Core Concepts
Understand workflows, services, and how Infinitic works
Production Setup
Set up Infinitic with production-ready storage and transport
Advanced Features
Explore retries, timeouts, versioning, and more
Examples
Browse real-world examples and patterns