Interface WebSocketConnector<CLIENT>

Type Parameters:
CLIENT - The client endpoint class
All Known Implementing Classes:
WebSocketConnectorImpl

public interface WebSocketConnector<CLIENT>
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.

Quarkus provides a CDI bean with bean type WebSocketConnector<CLIENT> and qualifier Default. The actual type argument of an injection point is used to determine the client endpoint. The type is validated during build and if it does not represent a client endpoint then the build fails.

This construct is not thread-safe and should not be used concurrently.

Connectors should not be reused. If you need to create multiple connections in a row you'll need to obtain a new connetor instance programmatically using Provider.get():

 import jakarta.enterprise.inject.Instance;

 @Inject
 Instance<WebSocketConnector<MyEndpoint>> connector;

 void connect() {
      var connection1 = connector.get().baseUri(uri)
                  .addHeader("Foo", "alpha")
                  .connectAndAwait();
      var connection2 = connector.get().baseUri(uri)
                  .addHeader("Foo", "bravo")
                  .connectAndAwait();
 }
 
See Also: