Skip to content

Commit 843b5a2

Browse files
committed
Sync documentation of main branch
1 parent 9485d8c commit 843b5a2

File tree

3 files changed

+66
-14
lines changed

3 files changed

+66
-14
lines changed

_data/versioned/main/index/quarkus.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ types:
392392
id: virtual-threads
393393
type: reference
394394
url: /guides/virtual-threads
395-
- title: WebSockets Next extension reference guide
395+
- title: WebSockets Next reference guide
396396
filename: websockets-next-reference.adoc
397397
summary: The quarkus-websockets-next extension provides a modern declarative API to define WebSocket server and client endpoints.
398398
categories: web

_data/versioned/main/index/relations.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7418,7 +7418,7 @@
74187418
url: /guides/websockets
74197419
type: guide
74207420
matches: 1
7421-
- title: WebSockets Next extension reference guide
7421+
- title: WebSockets Next reference guide
74227422
url: /guides/websockets-next-reference
74237423
type: reference
74247424
matches: 1
@@ -9598,7 +9598,7 @@
95989598
url: /guides/web-dependency-locator
95999599
type: guide
96009600
matches: 1
9601-
- title: WebSockets Next extension reference guide
9601+
- title: WebSockets Next reference guide
96029602
url: /guides/websockets-next-reference
96039603
type: reference
96049604
matches: 1
@@ -12209,7 +12209,7 @@
1220912209
url: /guides/websockets
1221012210
type: guide
1221112211
matches: 1
12212-
- title: WebSockets Next extension reference guide
12212+
- title: WebSockets Next reference guide
1221312213
url: /guides/websockets-next-reference
1221412214
type: reference
1221512215
matches: 1
@@ -21223,7 +21223,7 @@
2122321223
url: /guides/websockets
2122421224
type: guide
2122521225
matches: 1
21226-
- title: WebSockets Next extension reference guide
21226+
- title: WebSockets Next reference guide
2122721227
url: /guides/websockets-next-reference
2122821228
type: reference
2122921229
matches: 1
@@ -21277,7 +21277,7 @@
2127721277
url: /guides/websockets
2127821278
type: guide
2127921279
matches: 1
21280-
- title: WebSockets Next extension reference guide
21280+
- title: WebSockets Next reference guide
2128121281
url: /guides/websockets-next-reference
2128221282
type: reference
2128321283
matches: 1
@@ -21287,7 +21287,7 @@
2128721287
url: /guides/websockets-next-tutorial
2128821288
type: tutorial
2128921289
matches: 2
21290-
- title: WebSockets Next extension reference guide
21290+
- title: WebSockets Next reference guide
2129121291
url: /guides/websockets-next-reference
2129221292
type: reference
2129321293
matches: 2
@@ -21352,7 +21352,7 @@
2135221352
url: /guides/websockets
2135321353
type: guide
2135421354
matches: 2
21355-
- title: WebSockets Next extension reference guide
21355+
- title: WebSockets Next reference guide
2135621356
url: /guides/websockets-next-reference
2135721357
type: reference
2135821358
matches: 2
@@ -21377,7 +21377,7 @@
2137721377
type: guide
2137821378
matches: 1
2137921379
sameExtensions:
21380-
- title: WebSockets Next extension reference guide
21380+
- title: WebSockets Next reference guide
2138121381
url: /guides/websockets-next-reference
2138221382
type: reference
2138321383
matches: 1

_versions/main/guides/websockets-next-reference.adoc

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ and pull requests should be submitted there:
44
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
55
////
66
[id="websockets-next-reference-guide"]
7-
= WebSockets Next extension reference guide
7+
= WebSockets Next reference guide
88
:extension-status: preview
99
include::_attributes.adoc[]
1010
:numbered:
@@ -78,7 +78,7 @@ implementation("io.quarkus:quarkus-websockets-next")
7878

7979
== Endpoints
8080

81-
Both the server and client APIs allow you to define _endpoints_ that are used to consume and send messages.
81+
Both the <<server-api>> and <<client-api>> define _endpoints_ that are used to consume and send messages.
8282
The endpoints are implemented as CDI beans and support injection.
8383
Endpoints declare <<callback-methods,_callback methods_>> annotated with `@OnTextMessage`, `@OnBinaryMessage`, `@OnPong`, `@OnOpen`, `@OnClose` and `@OnError`.
8484
These methods are used to handle various WebSocket events.
@@ -559,6 +559,7 @@ This means that if an endpoint receives events `A` and `B` (in this particular o
559559
However, in some situations it is preferable to process events concurrently, i.e. with no ordering guarantees but also with no concurrency limits.
560560
For this cases, the `InboundProcessingMode#CONCURRENT` should be used.
561561

562+
[[server-api]]
562563
== Server API
563564

564565
=== HTTP server configuration
@@ -900,14 +901,15 @@ public class CustomTenantResolver implements TenantResolver {
900901
----
901902
For more information on Hibernate multitenancy, refer to the https://quarkus.io/guides/hibernate-orm#multitenancy[hibernate documentation].
902903

904+
[[client-api]]
903905
== Client API
904906

905907
[[client-connectors]]
906908
=== Client connectors
907909

908-
The `io.quarkus.websockets.next.WebSocketConnector<CLIENT>` is used to configure and create new connections for client endpoints.
909-
A CDI bean that implements this interface is provided and can be injected in other beans.
910-
The actual type argument is used to determine the client endpoint.
910+
A connector can be used to configure and open a new client connection backed by a client endpoint that is used to consume and send messages.
911+
Quarkus provides a CDI bean with bean type `io.quarkus.websockets.next.WebSocketConnector<CLIENT>` and default qualifer that can be injected in other beans.
912+
The actual type argument of an injection point is used to determine the client endpoint.
911913
The type is validated during build - if it does not represent a client endpoint the build fails.
912914

913915
Let’s consider the following client endpoint:
@@ -955,6 +957,31 @@ public class MyBean {
955957

956958
NOTE: If an application attempts to inject a connector for a missing endpoint, an error is thrown.
957959

960+
Connectors are not thread-safe and should not be used concurrently.
961+
Connectors should also not be reused.
962+
If you need to create multiple connections in a row you'll need to obtain a new connetor instance programmatically using `Instance#get()`:
963+
964+
[source, java]
965+
----
966+
import jakarta.enterprise.inject.Instance;
967+
968+
@Singleton
969+
public class MyBean {
970+
971+
@Inject
972+
Instance<WebSocketConnector<MyEndpoint>> connector;
973+
974+
void connect() {
975+
var connection1 = connector.get().baseUri(uri)
976+
.addHeader("Foo", "alpha")
977+
.connectAndAwait();
978+
var connection2 = connector.get().baseUri(uri)
979+
.addHeader("Foo", "bravo")
980+
.connectAndAwait();
981+
}
982+
}
983+
----
984+
958985
==== Basic connector
959986

960987
In the case where the application developer does not need the combination of the client endpoint and the connector, a _basic connector_ can be used.
@@ -991,6 +1018,31 @@ The basic connector is closer to a low-level API and is reserved for advanced us
9911018
However, unlike others low-level WebSocket clients, it is still a CDI bean and can be injected in other beans.
9921019
It also provides a way to configure the execution model of the callbacks, ensuring optimal integration with the rest of Quarkus.
9931020

1021+
Connectors are not thread-safe and should not be used concurrently.
1022+
Connectors should also not be reused.
1023+
If you need to create multiple connections in a row you'll need to obtain a new connetor instance programmatically using `Instance#get()`:
1024+
1025+
[source, java]
1026+
----
1027+
import jakarta.enterprise.inject.Instance;
1028+
1029+
@Singleton
1030+
public class MyBean {
1031+
1032+
@Inject
1033+
Instance<BasicWebSocketConnector> connector;
1034+
1035+
void connect() {
1036+
var connection1 = connector.get().baseUri(uri)
1037+
.addHeader("Foo", "alpha")
1038+
.connectAndAwait();
1039+
var connection2 = connector.get().baseUri(uri)
1040+
.addHeader("Foo", "bravo")
1041+
.connectAndAwait();
1042+
}
1043+
}
1044+
----
1045+
9941046
[[ws-client-connection]]
9951047
=== WebSocket client connection
9961048

0 commit comments

Comments
 (0)