Skip to content

Commit

Permalink
Merge pull request quarkusio#41410 from mkouba/issue-41393
Browse files Browse the repository at this point in the history
WebSockets Next: document WebSocket#inboundProcessingMode()
  • Loading branch information
mkouba authored Jun 25, 2024
2 parents 9f9b454 + c29d76f commit 0484069
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
9 changes: 9 additions & 0 deletions docs/src/main/asciidoc/websockets-next-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ void pong(Buffer data) {

NOTE: The server/client can also send unsolicited pong messages that may serve as a unidirectional heartbeat. There is a non-blocking variant: `WebSocketConnection#sendPong(Buffer)` and also a blocking variant: `WebSocketConnection#sendPongAndAwait(Buffer)`.

[[inbound-processing-mode]]
=== Inbound processing mode

WebSocket endpoints can define the mode used to process incoming events for a specific connection using the `@WebSocket#inboundProcessingMode()`, and `@WebSocketClient.inboundProcessingMode()` respectively.
An incoming event can represent a message (text, binary, pong), opening connection and closing connection.
By default, events are processed serially and ordering is guaranteed.
This means that if an endpoint receives events `A` and `B` (in this particular order) then callback for event `B` will be invoked after the callback for event `A` completed.
However, in some situations it is preferable to process events concurrently, i.e. with no ordering guarantees but also with no concurrency limits.
For this cases, the `InboundProcessingMode#CONCURRENT` should be used.

== Server API

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import io.smallrye.common.annotation.Experimental;

/**
* Defines the mode used to process incoming messages for a specific connection.
* WebSocket endpoints define the mode used to process incoming events for a specific connection.
* <p>
* An incoming event can represent a message (text, binary, pong), opening connection and closing connection.
*
* @see WebSocketConnection
* @see WebSocketClientConnection
Expand All @@ -12,12 +14,12 @@
public enum InboundProcessingMode {

/**
* Messages are processed serially, ordering is guaranteed.
* Events are processed serially, ordering is guaranteed.
*/
SERIAL,

/**
* Messages are processed concurrently, there are no ordering guarantees.
* Events are processed concurrently, there are no ordering guarantees.
*/
CONCURRENT,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public String endpointId() default FCQN_NAME;

/**
* The mode used to process incoming messages for a specific connection.
* The mode used to process incoming events for a specific connection.
*/
public InboundProcessingMode inboundProcessingMode() default InboundProcessingMode.SERIAL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public String clientId() default FCQN_NAME;

/**
* The execution mode used to process incoming messages for a specific connection.
* The mode used to process incoming events for a specific connection.
*/
public InboundProcessingMode inboundProcessingMode() default InboundProcessingMode.SERIAL;

Expand Down

0 comments on commit 0484069

Please sign in to comment.