Chapter 7. Atmosphere-Websocket


Atmosphere Websocket Servlet Component

Available as of Camel 2.14
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 Chapter 128, SERVLET component and uses the Atmosphere library to support the Websocket transport in various Servlet containers (e..g., Jetty, Tomcat, ...).
Unlike the Chapter 159, 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:
<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>
Copy to Clipboard Toggle word wrap

URI Format

atmosphere-websocket:///relative path[?options]
Copy to Clipboard Toggle word wrap

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.

Configuring URI to Read or Write Data

In the route below, Camel will read from the specified websocket connection.
from("atmosphere-websocket:///servicepath")
	    .to("direct:next");
Copy to Clipboard Toggle word wrap
And the equivalent Spring sample:
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="atmosphere-websocket:///servicepath"/>
    <to uri="direct:next"/>
  </route>
</camelContext>
Copy to Clipboard Toggle word wrap
In the route below, Camel will read from the specified websocket connection.
from("direct:next")
	    .to("atmosphere-websocket:///servicepath");
Copy to Clipboard Toggle word wrap
And the equivalent Spring sample:
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="direct:next"/>
    <to uri="atmosphere-websocket:///servicepath"/>
  </route>
</camelContext>
Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat