Interface BusEventsMixin
POST <servlet>/juneau-bus/session— opens a session and returns its grant. This is the protocol's only state-changing request, so every guard the application has applies to it.GET <servlet>/juneau-bus/stream/{sessionId}— a held-opentext/event-streamof bus frames, each asevent: bus. Gated by the capability in the path; an unknown or expired id, or another principal, is a404.
When BusPolicy.boundary() is set, both endpoints run its check: the full write check on the POST,
and on the GET whatever the boundary applies to a read (a LoopbackBoundary's Host check, a
CsrfBoundary's allowed hosts). The method judged is the one the request claims, so a GET carrying a
method parameter or an override header that claims a write gets the write check.
Example:
Example:
- Since:
- 10.0.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault JsonMapopenBusSession(RestRequest req, RestResponse res) [POST /juneau-bus/session] — opens a bus session.The bus this resource serves.default voidstreamBus(String id, RestRequest req, RestResponse res) [GET /juneau-bus/stream/{sessionId}] — streams the session's frames as Server-Sent Events.
-
Field Details
-
BUS_PREFIX
The servlet-relative prefix of both endpoints.- See Also:
-
SESSION_PATH
The session POST path.- See Also:
-
STREAM_PATH
The SSE stream path.- See Also:
-
-
Method Details
-
serverBus
The bus this resource serves.- Returns:
- The bus. Typically one per application, shared with the code that publishes.
-
openBusSession
[POST /juneau-bus/session] — opens a bus session.Body (at most 64 KB; a larger body is a 400):
{"v":1, "bridge":"ops", "transport":"sse"|"websocket", "downstream":[...], "upstream":[...]}. Returns the grant (sessionId,heartbeatMs,graceMs,downstreamwith each topic'sretain,upstreamandpaths). A refusal sets its status (400, 403, 429 withRetry-After, or 501) and returns{"code":..., "message":..., "denied":[...]}.- Parameters:
req- The REST request.res- The REST response.- Returns:
- The grant, or the refusal body.
-
streamBus
default void streamBus(@Path("sessionId") String id, RestRequest req, RestResponse res) throws IOException [GET /juneau-bus/stream/{sessionId}] — streams the session's frames as Server-Sent Events.Sends the resync, then live frames, until the client goes away or the bus closes the connection (bus closed, session expired, replaced by another connection, or too slow). Each frame is one
event: buswith the frame asdataand itsseq, when it has one, asid.The stream URL contains the session capability, so an application must not log request URIs for
/juneau-bus/stream/*. Juneau's own debug pipeline logs the request path of every completed call when the resolved logger is loggable atINFOor finer, andRestSessionlogs it atFINEwhen a client disconnects; keep those loggers coarser thanINFOfor resources that serve the bus.- Parameters:
id- The session's capability id.req- The REST request.res- The REST response.- Throws:
IOException- If the stream could not be written.
-