- Java 82.2%
- JavaScript 4.9%
- CSS 4.4%
- PowerShell 3.3%
- Dockerfile 2.7%
- Other 2.5%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| .mvn | ||
| docker | ||
| src | ||
| .dockerignore | ||
| .gitignore | ||
| build-image.ps1 | ||
| Dockerfile | ||
| Dockerfile.local | ||
| pom.xml | ||
| README.md | ||
fsc-notifications
Spring Boot (Java 21) consumer for the FSC notification service, for example RvIG updates when a BSN dies (sterfte) or changes. It is based on the consumer part of the Go simulation app:
https://gitlab.com/datastelsel.nl/federatief/simulation/simulation/-/tree/20eac16150f83ac501ef78ec228e39d4aa01c371/apps/notifications
What it does:
- Subscribe at the publisher on startup (
PUT /subscriptionsvia the FSC outway), using the grant hashes and event types from the configuration. Without this subscription the publisher sends nothing. The publisher upserts by webhook URL, so the app does this on every start. If it fails, it retries every minute. - Receive dataless CloudEvent notifications on
POST /eventsand store them in tablereceived_event(statusRECEIVED). It answers204right away. - Fetch the full event in the background (
GET /events/<dataref>via the outway). It stores the eventdataas JSON (statusFETCHED), or the error (statusFETCH_FAILED). - Process later: your processing reads
FETCHEDnotifications from the table or fromGET /notifications. When done, it marks them withPOST /notifications/{id}/processed(statusPROCESSED).
Every outbound call goes to OUTWAY_URL + path with header FSC-Grant-Hash: <grant hash>, with a 30s timeout.
sequenceDiagram
participant U as This app (consumer)
participant O as FSC Outway
participant P as Publisher (e.g. RvIG)
U->>O: PUT /subscriptions (FSC-Grant-Hash: subscribeGrantHash)
O->>P: {webhookUrl, eventTypes, callbackGrantHash}
P-->>U: {id} -> shown in the UI overview
P->>U: POST /events (dataless CloudEvent, via publisher's outway with callbackGrantHash)
Note over U: stored in received_event (RECEIVED), 204
U->>O: GET /events/<dataref> (FSC-Grant-Hash: subscribeGrantHash)
O->>P: GET /events/{id}
P-->>U: full CloudEvent -> data stored (FETCHED)
Note over U: your processing -> POST /notifications/{id}/processed (PROCESSED)
Configuration
| Env var | Default | Description |
|---|---|---|
OUTWAY_URL |
(required) | Base URL of your FSC outway, e.g. http://outway:8080 |
SUBSCRIBE_GRANT_HASH |
(required) | Grant hash of our contract with the publisher's notification service. Used to subscribe and to fetch events. |
CALLBACK_GRANT_HASH |
(required) | Grant hash of the publisher's contract with our /events service on our inway. Sent along when subscribing. |
EVENT_TYPES |
(required) | Comma-separated event types, e.g. sterfte |
WEBHOOK_URL |
/events |
Webhook path the publisher calls through its outway and our inway |
LISTEN_ADDRESS |
:8080 |
Go-style listen address (:8080, 0.0.0.0:9000) |
DB_URL |
jdbc:h2:file:./data/fsc-notifications |
JDBC URL. H2 and PostgreSQL drivers are included. |
DB_USERNAME |
sa |
|
DB_PASSWORD |
(empty) | |
DB_DDL_AUTO |
update |
Hibernate schema handling (update, validate, none) |
H2_CONSOLE_ENABLED |
true |
H2 console on /h2-console (set false in production) |
The app does not start when a required value is missing. Grant hashes come only from configuration, never from the UI.
Tables
received_event: one row per notification, with primary key id (the CloudEvent id).
| Column | |
|---|---|
id, type, source, specversion, event_time, dataref |
From the notification |
received_at |
When we received it |
status |
RECEIVED, FETCHED, FETCH_FAILED or PROCESSED |
datacontenttype, event_data |
Full event data (JSON text) after fetching. A BSN, if the publisher sends one, is in here. |
fetched_at |
When the data was fetched |
processed_at |
When it was marked processed |
error_message |
Why fetching failed |
The webhook is idempotent: a notification with an id that is already stored is ignored, and the app still returns 204.
If you used an earlier version, the old consumer_subscription table and fetched_via column are no longer used and can be dropped.
Endpoints
| Endpoint | |
|---|---|
POST /events |
Webhook for the publisher (src/main/resources/api/openapi-consumer.yaml) |
GET /notifications?status=FETCHED |
Notifications to process, oldest first. status defaults to FETCHED. |
GET /notifications/{id} |
One notification |
POST /notifications/{id}/processed |
FETCHED becomes PROCESSED: 204, or 409 for any other status, or 404 |
POST /notifications/{id}/refetch |
Retry fetching the data, e.g. after FETCH_FAILED: 202 |
GET / |
Read-only overview: subscription status, counts per status, latest notifications and activity (live via WebSocket /ws) |
GET /actuator/health, /actuator/health/liveness, /actuator/health/readiness |
Health probes for Kubernetes |
/h2-console |
H2 console (JDBC URL jdbc:h2:file:./data/fsc-notifications, user sa) |
src/main/resources/api/openapi-publisher.yaml is the publisher contract this app calls.
Errors use {"message": "..."}.
Note on dataref: the spec describes it as a URI, but the Go code fetches "/events/" + dataref, with dataref being the event id. This app does the same.
Build & run
Requires JDK 21 and Maven 3.9+.
Dependencies come from the UWV Azure DevOps feed UWVGegevensdiensten, configured in pom.xml. The setup is the same as doelgroepregister-app:
- Credentials: in
~/.m2/settings.xml, add a<server>with idUWVGegevensdiensten, usernameUWV, and your Azure DevOps PAT as the password. Never commit the token. .mvn/maven.config: enables preemptive authentication for the feed. Without it the feed can return 401.settings.xmlin this folder: proxy configuration only. Do not use-s settings.xmllocally, because it drops your credentials.
mvn -U clean package
$env:OUTWAY_URL="http://localhost:9081"
$env:SUBSCRIBE_GRANT_HASH="events-rvig"
$env:CALLBACK_GRANT_HASH="events-callback-uwv"
$env:EVENT_TYPES="sterfte"
java -jar target\fsc-notifications.jar
Open http://localhost:8080. The database file is created in .\data\.
Local test with the mock publisher
The mock setup has two parts:
- The Go simulation app running as publisher on
:9080. - A small fake outway on
:9081that routes on theFSC-Grant-Hashheader:events-rviggoes to the publisher,http://localhost:9080.events-callback-uwvgoes to this app,http://localhost:8080.
Steps:
- Start this app with the environment variables shown under Build & run. On startup it subscribes at the mock publisher, and the overview at http://localhost:8080 shows status
ACTIVE. - Open the publisher UI at http://localhost:9080 and publish a
sterfteevent. - The notification appears in the UI and in table
received_eventwith statusFETCHED.GET http://localhost:8080/notificationslists it.
The demo publisher's data has no BSN, only {"message","type"}. The real RvIG event determines where the BSN is in event_data.
Docker
The image contains no configuration. All variables are set at deploy time (Fieldlab images are public).
No Docker/Podman (UWV laptop): build-image.ps1 uses Jib through the UWV proxy:
$env:REGISTRY_USER = '<forgejo-user>'; $env:REGISTRY_TOKEN = '<token with package read/write>'
.\build-image.ps1 -Tag v0.1.0 # build + push
.\build-image.ps1 -Tag v0.1.0 -TarOnly # only target\jib-image.tar
| Where Maven Central is reachable (Forgejo CI, fieldlab laptop) | On the UWV network |
|---|---|
docker build --platform linux/amd64 -t code.digitaledienst.overheid.nl/uwv-devops/fsc-notifications:v0.1.0 . |
mvn -U clean package then docker build --platform linux/amd64 -f Dockerfile.local -t code.digitaledienst.overheid.nl/uwv-devops/fsc-notifications:v0.1.0 . |
Dockerfile builds from source and routes every Maven repository to Central (docker/maven-settings.xml). All dependencies are public. Dockerfile.local only wraps target/fsc-notifications.jar. Both images run as uid 10001.
Push:
docker login code.digitaledienst.overheid.nl -u <forgejo-user> # password = access token with package read/write
docker push code.digitaledienst.overheid.nl/uwv-devops/fsc-notifications:v0.1.0
Or push this code to a Forgejo repo: .forgejo/workflows/docker-build-push.yml builds on the vm runner with the org secrets REGISTRY_USER/REGISTRY_TOKEN. Tag v* → :<tag>, main → :main-<sha>.
Run locally:
docker run -p 8080:8080 -e OUTWAY_URL=http://outway:8080 -e SUBSCRIBE_GRANT_HASH=... -e CALLBACK_GRANT_HASH=... -e EVENT_TYPES=sterfte -v fsc-data:/app/data fsc-notifications