You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example, the type is `AgroalDataSource`, a `javax.sql.DataSource` subtype.
295
295
Because of this, you can also use `javax.sql.DataSource` as the injected type.
296
296
297
+
===== Oracle considerations
298
+
299
+
As documented in https://github.com/quarkusio/quarkus/issues/36265[issue #36265],
300
+
Oracle has a very weird behavior of committing the uncommitted transactions on connection closing.
301
+
302
+
Which means that when stopping Quarkus for instance, in progress transactions might be committed even if incomplete.
303
+
304
+
Given that is not the expected behavior and that it could lead to data loss, we added an interceptor that rolls back any unfinished transactions at connection close,
305
+
provided you are not using XA (in which case the transaction manager handles things for you).
306
+
307
+
If this behavior introduced in 3.18 causes issues for your specific workload, you can disable it by setting the `-Dquarkus-oracle-no-automatic-rollback-on-connection-close` system property to `true`.
308
+
Please take the time to report your use case in our https://github.com/quarkusio/quarkus/issues[issue tracker] so that we can adjust this behavior if needed.
Both the <<server-api>> and <<client-api>> define _endpoints_ that are used to consume and send messages.
81
81
The endpoints are implemented as CDI beans and support injection.
82
-
Endpoints declare <<callback-methods,_callback methods_>> annotated with `@OnTextMessage`, `@OnBinaryMessage`, `@OnPong`, `@OnOpen`, `@OnClose` and `@OnError`.
82
+
Endpoints declare <<callback-methods,_callback methods_>> annotated with `@OnTextMessage`, `@OnBinaryMessage`, `@OnPingMessage`, `@OnPongMessage`, `@OnOpen`, `@OnClose` and `@OnError`.
83
83
These methods are used to handle various WebSocket events.
84
84
Typically, a method annotated with `@OnTextMessage` is called when the connected client sends a message to the server and vice versa.
85
85
@@ -210,6 +210,7 @@ A WebSocket endpoint may declare:
210
210
211
211
* At most one `@OnTextMessage` method: Handles the text messages from the connected client/server.
212
212
* At most one `@OnBinaryMessage` method: Handles the binary messages from the connected client/server.
213
+
* At most one `@OnPingMessage` method: Handles the ping messages from the connected client/server.
213
214
* At most one `@OnPongMessage` method: Handles the pong messages from the connected client/server.
214
215
* At most one `@OnOpen` method: Invoked when a connection is opened.
215
216
* At most one `@OnClose` method: Executed when the connection is closed.
@@ -551,39 +552,55 @@ Item find(Item item) {
551
552
1. Specify the codec to use for the deserialization of the incoming message
552
553
2. Specify the codec to use for the serialization of the outgoing message
553
554
554
-
=== Ping/pong messages
555
+
=== Ping/Pong messages
555
556
556
557
A https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.2[ping message] may serve as a keepalive or to verify the remote endpoint.
557
558
A https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.3[pong message] is sent in response to a ping message and it must have an identical payload.
558
559
559
-
Server/client endpoints automatically respond to a ping message sent from the client/server.
560
-
In other words, there is no need for `@OnPingMessage` callback declared on an endpoint.
560
+
==== Sending ping messages
561
561
562
-
The server can send ping messages to a connected client.
563
-
`WebSocketConnection`/`WebSocketClientConnection` declare methods to send ping messages; there is a non-blocking variant: `sendPing(Buffer)` and a blocking variant: `sendPingAndAwait(Buffer)`.
564
-
By default, the ping messages are not sent automatically.
565
-
However, the configuration properties `quarkus.websockets-next.server.auto-ping-interval` and `quarkus.websockets-next.client.auto-ping-interval` can be used to set the interval after which, the server/client sends a ping message to a connected client/server automatically.
562
+
Ping messages are optional and not sent by default. However, server and client endpoints can be configured to automatically send ping messages on an interval.
<1> Sends a ping message from the server to a connected client every 2 seconds.
569
+
<1> Sends a ping message from the server to each connected client every 2 seconds.
570
+
<2> Sends a ping message from all connected client instances to their remote servers every 10 seconds.
572
571
573
-
The `@OnPongMessage` annotation is used to define a callback that consumes pong messages sent from the client/server.
574
-
An endpoint must declare at most one method annotated with `@OnPongMessage`.
572
+
Servers and clients can send ping messages programmatically at any time using `WebSocketConnection` or `WebSocketClientConnection`.
573
+
There is a non-blocking variant: `Sender#sendPing(Buffer)` and a blocking variant: `Sender#sendPingAndAwait(Buffer)`.
574
+
575
+
==== Sending pong messages
576
+
577
+
Server and client endpoints will always respond to a ping message sent from the remote party with a corresponding pong message, using the application data from the ping message.
578
+
This behavior is built-in and requires no additional code or configuration.
579
+
580
+
Servers and clients can send unsolicited pong messages that may serve as a unidirectional heartbeat using `WebSocketConnection` or `WebSocketClientConnection`. There is a non-blocking variant: `Sender#sendPong(Buffer)` and a blocking variant: `Sender#sendPongAndAwait(Buffer)`.
581
+
582
+
==== Handling ping/pong messages
583
+
584
+
Because ping messages are handled automatically and pong messages require no response, it is not necessary to write handlers for these messages to comply with the WebSocket protocol.
585
+
However, it is sometimes useful to know when ping or pong messages are received by an endpoint.
586
+
587
+
The `@OnPingMessage` and `@OnPongMessage` annotations can be used to define callbacks that consume ping or pong messages sent from the remote party.
588
+
An endpoint may declare at most one `@OnPingMessage` callback and at most one `@OnPongMessage` callback.
575
589
The callback method must return either `void` or `Uni<Void>` (or be a Kotlin `suspend` function returning `Unit`), and it must accept a single parameter of type `Buffer`.
576
590
577
591
[source,java]
578
592
----
593
+
@OnPingMessage
594
+
void ping(Buffer data) {
595
+
// an incoming ping that will automatically receive a pong
596
+
}
597
+
579
598
@OnPongMessage
580
599
void pong(Buffer data) {
581
-
// ....
600
+
// an incoming pong in response to the last ping sent
582
601
}
583
602
----
584
603
585
-
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)`.
0 commit comments