Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Questo contenuto non è disponibile nella lingua selezionata.
Chapter 4. AHC-WS
Async Http Client (AHC) Websocket Client Component Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Available as of Camel 2.14
The ahc-ws component provides Websocket based endpoints for a client communicating with external servers over Websocket (as a client opening a websocket connection to an external server). The component uses the Chapter 3, AHC component that in turn uses the Async Http Client library.
Maven users will need to add the following dependency to their
pom.xml
for this component:
URI Format Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
ahc-ws://hostname[:port][/resourceUri][?options] ahc-wss://hostname[:port][/resourceUri][?options]
ahc-ws://hostname[:port][/resourceUri][?options]
ahc-wss://hostname[:port][/resourceUri][?options]
Will by default use port 80 for ahc-ws and 443 for ahc-wss.
AHC-WS Options Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
As the AHC-WS component is based on the AHC component, you can use the various configuration options of the AHC component.
Writing and Reading Data over Websocket Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
An ahc-ws endpoint can either write data to the socket or read from the socket, depending on whether the endpoint is configured as the producer or the consumer, respectively.
Configuring URI to Write or Read Data Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
In the route below, Camel will write to the specified websocket connection.
from("direct:start") .to("ahc-ws://targethost");
from("direct:start")
.to("ahc-ws://targethost");
And the equivalent Spring sample:
In the route below, Camel will read from the specified websocket connection.
from("ahc-ws://targethost") .to("direct:next");
from("ahc-ws://targethost")
.to("direct:next");
And the equivalent Spring sample: