Skip to content

Commit

Permalink
WebSockets Next: document WebSocket#inboundProcessingMode()
Browse files Browse the repository at this point in the history
- resolves #41393
  • Loading branch information
mkouba committed Jun 25, 2024
1 parent 32d0c2d commit c29d76f
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)`.

Check warning on line 522 in docs/src/main/asciidoc/websockets-next-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsWarnings] Consider using 'might (for possiblity)' or 'can (for ability)' rather than 'may' unless updating existing content that uses the term. Raw Output: {"message": "[Quarkus.TermsWarnings] Consider using 'might (for possiblity)' or 'can (for ability)' rather than 'may' unless updating existing content that uses the term.", "location": {"path": "docs/src/main/asciidoc/websockets-next-reference.adoc", "range": {"start": {"line": 522, "column": 59}}}, "severity": "WARNING"}

[[inbound-processing-mode]]

Check warning on line 524 in docs/src/main/asciidoc/websockets-next-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.HeadingPunctuation] Do not use end punctuation in headings. Raw Output: {"message": "[Quarkus.HeadingPunctuation] Do not use end punctuation in headings.", "location": {"path": "docs/src/main/asciidoc/websockets-next-reference.adoc", "range": {"start": {"line": 524, "column": 18}}}, "severity": "INFO"}
=== 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.

Check warning on line 527 in docs/src/main/asciidoc/websockets-next-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/websockets-next-reference.adoc", "range": {"start": {"line": 527, "column": 87}}}, "severity": "INFO"}
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.

Check warning on line 531 in docs/src/main/asciidoc/websockets-next-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsWarnings] Consider using 'that is' rather than 'i.e.' unless updating existing content that uses the term. Raw Output: {"message": "[Quarkus.TermsWarnings] Consider using 'that is' rather than 'i.e.' unless updating existing content that uses the term.", "location": {"path": "docs/src/main/asciidoc/websockets-next-reference.adoc", "range": {"start": {"line": 531, "column": 67}}}, "severity": "WARNING"}

Check failure on line 531 in docs/src/main/asciidoc/websockets-next-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsErrors] Use 'you' rather than 'i'. Raw Output: {"message": "[Quarkus.TermsErrors] Use 'you' rather than 'i'.", "location": {"path": "docs/src/main/asciidoc/websockets-next-reference.adoc", "range": {"start": {"line": 531, "column": 67}}}, "severity": "ERROR"}
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 c29d76f

Please sign in to comment.