FlowGuard is an enterprise integration reliability platform designed to guarantee durable message acceptance, duplicate prevention, asynchronous database-backed worker processing, bounded exponential retries, and audited manual operator recovery for high-value asynchronous integration pipelines.
Built as a modular monolith adhering strictly to Hexagonal Architecture (Ports and Adapters) and Domain-Driven Design (DDD).
FlowGuard enforces an inward-facing dependency graph. The core domain is completely isolated from frameworks, persistence, and network protocols.
[Inbound Adapters (Driving)] [Outbound Adapters (Driven)]
- REST API (MessageController) - PostgreSQL Message Repository
- Ops API (OperationsController) - PostgreSQL Idempotency Repository
- Worker Schedulers (SKIP LOCKED) - PostgreSQL Attempt & Audit Adapters
- Lease Recovery Engine - Outbound HTTP Delivery Adapter
\ /
\ /
[Application Core / Use Cases & Ports]
- Input Ports (Submit, Search, Retry, Ops)
- Output Ports (MessagePort, DeliveryPort, AuditPort)
|
v
[Pure Domain Model (POJOs)]
- IntegrationMessage Aggregate Root
- Value Objects (MessageId, ClientId, DestinationKey)
- MessageLifecyclePolicy & RetryPolicy
- Pure Domain Isolation:
com.flowguard.core.domain..contains POJOs with zero dependencies on Spring, JPA, SQL, Jackson, or cloud SDKs. - Atomic Idempotent Ingestion: Guarantees atomic insertion of message and idempotency record (
client_id, key_digest) in a single database transaction. - Worker Lease Fencing: Workers claim batches using
SELECT ... FOR UPDATE SKIP LOCKEDand assign a uniquelease_token. Completions conditionally matchlease_tokento prevent stale or crashed workers from overwriting newer state. - Short DB Transactions: Remote deliveries execute outside database transactions to prevent connection pool exhaustion.
- Reconciliation Safety: Downstream socket timeouts on non-idempotent targets route to
RECONCILIATION_REQUIREDand strictly forbid automatic retries.
- Java 21 LTS
- Docker & Docker Compose (for PostgreSQL)
docker compose up -d./mvnw spring-boot:runFlowGuard will start on http://localhost:8080 and run Flyway database migrations automatically.
Base URL: /api/v1
All error responses adhere to RFC 9457 Problem Details (application/problem+json).
curl -i -X POST http://localhost:8080/api/v1/messages \
-H "Content-Type: application/json" \
-H "Idempotency-Key: idemp-2026-10-001" \
-H "X-Client-Id: client_acme_corp" \
-H "X-Correlation-ID: corr-txn-9841" \
-d '{
"messageType": "PAYROLL_DISBURSEMENT_V1",
"destinationKey": "LEDGER_MAIN",
"sourceSystem": "HR_WORKDAY",
"externalReference": "PAY-OCT-2026",
"payload": {"employeeId": "EMP-4819", "amount": 3500.00, "currency": "USD"}
}'Response: 202 Accepted
{
"messageId": "9a0a8112-2591-4965-9831-2792c306d8a2",
"status": "QUEUED",
"idempotentReplay": false,
"createdAt": "2026-10-18T01:30:00Z"
}curl "http://localhost:8080/api/v1/messages?status=DEAD_LETTERED&page=0&size=10" \
-H "X-Client-Id: client_acme_corp"curl "http://localhost:8080/api/v1/messages/9a0a8112-2591-4965-9831-2792c306d8a2/attempts" \
-H "X-Client-Id: client_acme_corp"curl -i -X POST "http://localhost:8080/api/v1/messages/9a0a8112-2591-4965-9831-2792c306d8a2/retries" \
-H "Content-Type: application/json" \
-H "X-Actor-Id: ops-engineer-42" \
-d '{
"reason": "Downstream ledger endpoint restored and verified ready for re-drive."
}'Response: 202 Accepted
curl -i -X POST "http://localhost:8080/api/v1/messages/9a0a8112-2591-4965-9831-2792c306d8a2/cancel" \
-H "Content-Type: application/json" \
-H "X-Actor-Id: ops-engineer-42" \
-H "X-Client-Id: client_acme_corp" \
-d '{
"reason": "Order cancelled by customer before dispatch."
}'Response: 202 Accepted
curl "http://localhost:8080/api/v1/operations/summary" \
-H "X-Scope: operations:read"curl -i -X POST http://localhost:8080/api/v1/messages/batch \
-H "Content-Type: application/json" \
-H "X-Client-Id: client_acme_corp" \
-d '{
"items": [
{
"idempotencyKey": "batch-item-001",
"messageType": "ORDER_SYNC",
"destinationKey": "LEDGER_MAIN",
"payload": {"orderId": "ORD-101", "amount": 150.00}
},
{
"idempotencyKey": "batch-item-002",
"messageType": "ORDER_SYNC",
"destinationKey": "LEDGER_MAIN",
"payload": {"orderId": "ORD-102", "amount": 250.00}
}
]
}'Response: 202 Accepted (or 200 OK if all items are idempotent replays)
{
"totalCount": 2,
"acceptedCount": 2,
"replayedCount": 0,
"items": [
{
"index": 0,
"idempotencyKey": "batch-item-001",
"messageId": "9a0a8112-2591-4965-9831-2792c306d8a2",
"status": "QUEUED",
"idempotentReplay": false
},
{
"index": 1,
"idempotencyKey": "batch-item-002",
"messageId": "1b0a8234-3191-4965-9831-2792c306d8b3",
"status": "QUEUED",
"idempotentReplay": false
}
]
}curl "http://localhost:8080/api/v1/audit-events?action=MANUAL_RETRY&page=0&size=20" \
-H "X-Scope: audit:read"Execute the complete test suite (124 automated unit tests, integration tests, E2E Testcontainers suite, and ArchUnit architecture verification rules):
./mvnw clean testFlowGuard includes a comprehensive E2E test suite (FlowGuardEnterpriseE2ETest) running against a live PostgreSQL 16 Alpine container:
- Phase 1 & 2: Message submission (
202 Accepted), idempotent replay (200 OK), payload conflict detection (409 Conflict), and SSRF raw URL rejection (400 Bad Request). - Phase 3: Deterministic worker claim with
SELECT ... FOR UPDATE SKIP LOCKED, monotonic attempt tracking, and transition toSUCCEEDED. - Phase 4: Simulated ambiguous timeouts triggering
RECONCILIATION_REQUIREDquarantine (prohibiting automatic retries). - Phase 5: Audited manual retry re-queueing to
QUEUEDwith immutable audit log generation. - Phase 8: Explicit message cancellation prior to dispatch (
CANCELLED). - Phase 9: Bulk message ingestion (
POST /api/v1/messages/batch) and paged audit event querying (GET /api/v1/audit-events). - Operations & Actuator: Health and metrics inspection (
/actuator/health,/actuator/metrics).
To run only the E2E test suite:
./mvnw test -Dtest=FlowGuardEnterpriseE2ETestArchUnit rules in HexagonalArchitectureTest continuously assert:
- Domain layer has zero framework imports (
org.springframework,jakarta.persistence,com.fasterxml.jackson). - Domain model has no outward dependencies on application or adapter layers.
- Application core communicates with external systems exclusively via ports.
- Inbound adapters never cross-communicate directly with outbound adapters.
For detailed runbooks on failure triage, handling RECONCILIATION_REQUIRED ambiguous states, worker lease recovery, and alert thresholds, see:
π FlowGuard Operational Runbook
FlowGuard is proprietary enterprise integration reliability software. All rights reserved.