= Atmosphere Websocket Component
:doctitle: Atmosphere Websocket
:shortname: atmosphere-websocket
:artifactid: camel-atmosphere-websocket
:description: Expose WebSocket endpoints using the Atmosphere framework.
:since: 2.14
:supportlevel: Stable
:component-header: Both producer and consumer are supported
//Manually maintained attributes
:camel-spring-boot-name: atmosphere-websocket

*Since Camel {since}*

*{component-header}*

The Atmosphere-Websocket component provides Websocket
based endpoints for a servlet communicating with
external clients over Websocket (as a servlet accepting websocket
connections from external clients). +
The component uses the xref:servlet-component.adoc[SERVLET] component and uses
the https://github.com/Atmosphere/atmosphere[Atmosphere] library to
support the Websocket transport in various Servlet containers (e..g.,
Jetty, Tomcat, ...).

Unlike the
xref:websocket-component.adoc[Websocket]
component that starts the embedded Jetty server, this component uses the
servlet provider of the container.

Maven users will need to add the following dependency to
their `pom.xml` for this component:

[source,xml]
------------------------------------------------------------
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-atmosphere-websocket</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------


// component-configure options: START

// component-configure options: END

// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
// component options: END

// endpoint options: START

// endpoint options: END

// component headers: START
include::partial$component-endpoint-headers.adoc[]
// component headers: END

== Reading and Writing Data over Websocket

An atmopshere-websocket 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.

== Examples

=== Consumer Example

In the route below, Camel will read from the specified websocket
connection.

[source,java]
-------------------------------------------
from("atmosphere-websocket:///servicepath")
        .to("direct:next");
-------------------------------------------

And the equivalent Spring sample:

[source,xml]
------------------------------------------------------------
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="atmosphere-websocket:///servicepath"/>
    <to uri="direct:next"/>
  </route>
</camelContext>
------------------------------------------------------------

=== Producer Example

In the route below, Camel will write to the specified websocket
connection.

[source,java]
---------------------------------------------------
from("direct:next")
        .to("atmosphere-websocket:///servicepath");
---------------------------------------------------

And the equivalent Spring sample:

[source,xml]
------------------------------------------------------------
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="direct:next"/>
    <to uri="atmosphere-websocket:///servicepath"/>
  </route>
</camelContext>
------------------------------------------------------------


include::spring-boot:partial$starter.adoc[]
