GET /v1/stream connection open in a daemon thread. Whenever the Nexus backend emits a change event (config.updated, flag.toggled, secret.created, resync, …), the SDK triggers an immediate full sync - so the cache is updated within milliseconds of the change, instead of waiting for the next TTL tick.
Auth
Java uses theX-Nexus-API-Key header on all endpoints, including /stream, via Java 11’s stdlib HttpClient. The key is never passed as a ?key= query parameter. (All Nexus SDKs send the key in this header - the browser SDKs do too, using fetch-based streaming rather than the EventSource API.)
Enabling it
The auto-configuration callsconnectStream() automatically after the initial sync (controlled by nexus.stream):
What happens under the hood
- The SDK opens an HTTP streaming response via
HttpClient.send(...)withAccept: text/event-streamand theX-Nexus-API-Keyheader. - The server immediately sends a
resyncevent, which causes the SDK to callsync()once to align with the current state. - The connection stays open. Every change event triggers another full sync.
- While the stream is up, the polling TTL is bumped to 60 s as a safety net.
Reconnection
Any transport error (server restart, TCP drop, network blip) triggers a reconnect with exponential backoff: 1s - 2s - 4s - 8s - 16s - 30s (capped at 30s). AfterMAX_STREAM_ERRORS consecutive transport errors the SDK does not fall back permanently. Instead it sleeps according to the sseReconnectCooldown schedule and then retries SSE automatically.
client.isStreamConnected() - it returns false while the SDK is sleeping between reconnect attempts.
The reconnect cooldown schedule defaults to [5, 10, 20, 40, 60] minutes and can be tuned with the sseReconnectCooldown config option (see Configuration).
429 Too Many Requests
Every project tier has a per-service stream connection limit:
Behaviour (v0.6.0+)
The SDK’s 429 handling is presence-conditional onRetry-After:
- With a parseable
Retry-Afterheader - the SDK parses the value, clamps to[5 s, 5 min], firesobserver.onFallback("rate-limited")so dashboards can record the rate-limit episode, thenThread.sleeps for the clamped delay (interrupt-aware) and continues the reconnect loop. The 429 does NOT count towardMAX_STREAM_ERRORS. - Without a parseable
Retry-Afterheader - the SDK firesobserver.onFallback("rate-limited")and schedules a reconnect using thesseReconnectCooldownschedule (default 5 - 10 - 20 - 40 - 60 minutes). SSE is retried automatically after the cooldown; there is no permanent fallback.
NexusClient. Existing NexusStreamObserver implementations will simply observe more onFallback("rate-limited") callbacks during rate-limit episodes, each followed by an automatic reconnect rather than a permanent fallback.
Disabling SSE at runtime
What events trigger a sync
Lifecycle
The SSE thread is bound to theNexusClient bean. The auto-configuration registers destroyMethod = "close", so the thread is stopped cleanly when the Spring context shuts down.
