Spring Boot service that persists FINT Flyt process instances, orchestrates Kafka events, and exposes internal APIs for retrying and cleaning up instance state. It coordinates with downstream integrations, and maintains retention policies.
- Transactional REST API — internal controller secures retry endpoints under
/api/intern/handlinger/instanser. - Kafka orchestration — produces retry/deletion events and consumes lifecycle notifications to keep state in sync.
- Scheduled hygiene — daily cleanup removes stale instances according to a configurable retention window.
- Postgres persistence — stores instance payloads with JPA mappings for retrieval, batching, and deletion.
| Component | Responsibility |
|---|---|
InstanceRetryController |
Handles single/batch retry requests and triggers Kafka events; lives under the internal API namespace. |
InstanceService |
Core business logic for CRUD operations, mapping DTOs, and coordinating downstream producers. |
InstanceRepository |
Spring Data JPA repository that persists and queries instance entities in Postgres. |
InstanceCleanupService |
Scheduled service that deletes instances older than novari.flyt.instance-service.time-to-keep-instance-in-days. |
InstanceFlowHeadersForRegisteredInstanceRequestProducerService |
Requests flow headers used when emitting retry/deleted events. |
InstanceRequestedForRetryEventProducerService |
Publishes instance retry requests to Kafka and provisions the topic with retention configuration. |
InstanceDeletedEventProducerService |
Emits instance-deleted events whenever records are purged. |
InstanceRetryRequestErrorEventProducerService |
Publishes general system errors when retries fail after headers were resolved. |
InstanceReceivedEventConsumerConfiguration / InstanceDispatchedConsumerConfiguration |
Configures Kafka consumers that react to lifecycle events to stay aligned with upstream flows. |
Base path: /api/intern/handlinger/instanser
| Method | Path | Description | Request body | Response |
|---|---|---|---|---|
POST |
/{instanceId}/prov-igjen |
Retry a specific instance by ID. | – | 200 OK or 404/500 on failure. |
POST |
/prov-igjen/batch |
Retry multiple instances in one request. | JSON array of instance IDs (List<Long>). |
200 OK; logs per-item failures. |
Errors surface as standard Spring MVC responses: 404 Not Found when an instance is missing, 500 Internal Server Error for unexpected issues.
- Produces the following topics via the FINT Kafka template services:
instance-requested-for-retryinstance-registered,instance-registration-error,instance-deleted, andinstance-retry-request-error
- Consumes instance lifecycle events through
InstanceReceivedEventConsumerConfigurationandInstanceDispatchedConsumerConfigurationto coordinate retries and header lookups. - Topic retention is governed by
novari.flyt.instance-service.kafka.topic.instance-processing-events-retention-time(default four days). A millisecond suffix variant (...-retention-time-ms) is also supported for services that require explicit units.
InstanceCleanupService.cleanUp() runs every 24 hours (initial delay 30 seconds) and deletes instances older than novari.flyt.instance-service.time-to-keep-instance-in-days (defaults to 60). When a record is removed the service publishes instance-deleted events.
The application composes the shared Spring profiles flyt-kafka, flyt-logging, flyt-postgres, and flyt-resource-server.
Key properties:
| Property | Description |
|---|---|
fint.application-id |
Defaults to fint-flyt-instance-service. |
novari.flyt.instance-service.time-to-keep-instance-in-days |
Retention window used by the cleanup job (default 60). |
novari.flyt.instance-service.kafka.topic.instance-processing-events-retention-time |
Duration string used to configure Kafka topic retention (default 4d). |
spring.datasource.* |
Provide JDBC connection details for Postgres; overlays inject environment-specific secrets. |
spring.security.oauth2.resourceserver.jwt.issuer-uri |
OAuth issuer for protected internal endpoints. |
novari.flyt.resource-server.security.api.internal-client |
Defines clients permitted to call internal APIs. |
Secrets referenced in Kustomize overlays must provide database credentials, OAuth settings, and Kafka access.
Prerequisites:
- Java 21+
- Docker (for the bundled Postgres helper) and access to a Kafka cluster
- Gradle (wrapper included)
Useful commands:
./start-postgres # launch a disposable Postgres on localhost:5433
./gradlew clean build # compile and run tests
./gradlew bootRun # start the service with default profiles
./gradlew test # run unit testsConfigure SPRING_PROFILES_ACTIVE or override properties (e.g. novari.flyt.instance-service.time-to-keep-instance-in-days) as needed for local experiments. Point Kafka settings at your development broker (typically localhost:9092).
Kustomize layout:
kustomize/base/contains the sharedApplicationresource and supporting Kubernetes manifests.kustomize/overlays/<org>/<env>/applies namespace labels, Kafka ACLs, and URL prefixes references per organization and environment.
Templates are centralized in kustomize/templates/:
overlay.yaml.tpl— envsubst template used for every overlay.
Regenerate overlays after changing the template or rendering logic:
./script/render-overlay.shThe script injects namespace-specific values (base paths, Kafka topics, role mappings) and rewrites each kustomization.yaml in place.
- Uses the FINT OAuth2 resource server setup for JWT validation (
spring.security.oauth2.resourceserver.jwt.issuer-uri). - Restricts internal APIs to trusted clients defined via
novari.flyt.resource-server.security.api.internal-client.
- Readiness and liveness:
/actuator/health. - Metrics:
/actuator/prometheus. - Structured logging via shared FINT logging profile; Kafka and cleanup events emit detailed log messages for traceability.
- When introducing new instance states, ensure the corresponding Kafka producers/consumers are updated and retention properties remain valid.
InstanceService.deleteAllOlderThanpublishes deletion events extending tests when altering cleanup semantics.- If additional organizations require custom role mappings for overlays, update
script/render-overlay.shto reflect the new rules.
- Create a topic branch for your change.
- Run
./gradlew test(and additional checks) before raising a PR. - If you modify Kustomize templates or overlay logic, rerun
./script/render-overlay.shand commit the generated manifests. - Add or adjust tests for any new behaviour or edge cases.
FINT Flyt Instance Service is maintained by the FINT Flyt team. Reach out via the internal Slack channel or open an issue in this repository for questions or enhancements.