// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-vertx-websocket"]
= Vert.x WebSocket
:linkattrs:
:cq-artifact-id: camel-quarkus-vertx-websocket
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Camel WebSocket support with Vert.x
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: 1.1.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.1.0##
endif::[]

This extension enables you to create WebSocket endpoints to that act as either a WebSocket server, or as a client to connect an existing WebSocket .

It is built on top of the Eclipse Vert.x HTTP server provided by the `quarkus-vertx-http` extension.


[id="extensions-vertx-websocket-whats-inside"]
== What's inside

* xref:{cq-camel-components}::vertx-websocket-component.adoc[Vert.x WebSocket component], URI syntax: `vertx-websocket:host:port/path`

Please refer to the above link for usage and configuration details.

[id="extensions-vertx-websocket-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-vertx-websocket[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-vertx-websocket</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-vertx-websocket-usage"]
== Usage
[id="extensions-vertx-websocket-usage-vert-x-websocket-consumers"]
=== Vert.x WebSocket consumers

When you create a Vert.x WebSocket consumer (E.g. with `from("vertx-websocket")`), the host and port configuration in the URI are redundant since the WebSocket will always be hosted on
the Quarkus HTTP server.

The configuration of the consumer can be simplified to only include the resource path of the WebSocket. For example.

[source,java]
----
from("vertx-websocket:/my-websocket-path")
    .setBody().constant("Hello World");
----

NOTE: While you do not need to explicitly configure the host/port on the vertx-websocket consumer. If you choose to,
the host & port must exactly match the value of the Quarkus HTTP server configuration values for `quarkus.http.host` and `quarkus.http.port`.
Otherwise, an exception will be thrown at runtime.

[id="extensions-vertx-websocket-usage-vert-x-websocket-producers"]
=== Vert.x WebSocket producers

Similar to above, if you want to produce messages to the internal Vert.x WebSocket consumer, then you can omit the host and port from the endpoint URI.

[source,java]
----
from("vertx-websocket:/my-websocket-path")
    .log("Got body: ${body}");

from("direct:sendToWebSocket")
    .log("vertx-websocket:/my-websocket-path");
----

Or alternatively, you can refer to the full host & port configuration for the Quarkus HTTP server.

[source,java]
----
from("direct:sendToWebSocket")
    .log("vertx-websocket:{{quarkus.http.host}}:{{quarkus.http.port}}/my-websocket-path");
----

When producing messages to an external WebSocket server, then you must always provide the host name and port (if required).


[id="extensions-vertx-websocket-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

[id="extensions-vertx-websocket-configuration-vert-x-websocket-server-configuration"]
=== Vert.x WebSocket server configuration

Configuration of the Vert.x WebSocket server is managed by Quarkus. Refer to the https://quarkus.io/guides/all-config#quarkus-vertx-http_quarkus-vertx-http-eclipse-vert.x-http[Quarkus HTTP configuration guide]
for the full list of configuration options.

To configure SSL for the Vert.x WebSocket server, follow the https://quarkus.io/guides/http-reference#ssl[secure connections with SSL guide].
Note that configuring the server for SSL with `SSLContextParameters` is not currently supported.

[id="extensions-vertx-websocket-configuration-character-encodings"]
=== Character encodings

Check the xref:user-guide/native-mode.adoc#charsets[Character encodings section] of the Native mode guide if you expect
your application to send or receive requests using non-default encodings.

