Author: buildbot Date: Sat Mar 17 15:18:11 2012 New Revision: 808962 Log: Production update by buildbot for camel Added: websites/production/camel/content/websocket.html Modified: websites/production/camel/content/cache/main.pageCache websites/production/camel/content/camel-2100-release.html Modified: websites/production/camel/content/cache/main.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/camel/content/camel-2100-release.html ============================================================================== --- websites/production/camel/content/camel-2100-release.html (original) +++ websites/production/camel/content/camel-2100-release.html Sat Mar 17 15:18:11 2012 @@ -96,7 +96,7 @@

New Components

- +

DSL Changes

Added: websites/production/camel/content/websocket.html ============================================================================== --- websites/production/camel/content/websocket.html (added) +++ websites/production/camel/content/websocket.html Sat Mar 17 15:18:11 2012 @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + Apache Camel: Websocket + + + +
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + +
+

Websocket Component

+

Available as of Camel 2.10

+ +

The websocket component provides websocket endpoints for communicating with clients using websocket.

+ +

URI format

+ +
+
+websocket://hostname[:port][/resourceUri][?options]
+
+
+ +

You can append query options to the URI in the following format, ?option=value&option=value&...

+ +

Options

+ +

None.

+ +

Message Headers

+ +

The websocket component uses 2 headers to indicate to either send messages back to a single/current client, or to all clients.

+ +
+
Key Description
WebsocketConstants.SEND_TO_ALL Sends the message to all clients which are currently connected.
WebsocketConstants.CONNECTION_KEY Sends the message to the client with the given connection key.
+
+
+ +

Component Options

+ +

The WebsocketComponent must be configured prior to use, to setup host, to act as a websocket server.

+ +
+
+
Option Default Description
Host 0.0.0.0 The hostname.
Port 9292 The port number.
StaticResources null Path for static resources such as index.html files etc.
+
+ + +

Usage

+ +

In this example we let Camel exposes a websocket server which clients can communicate with. The websocket server uses the default host and port, which would be 0.0.0.0:9292.
+The example will send back an echo of the input. To send back a message, we need to send the transformed message to the same endpoint "websocket://echo". This is needed
+because by default the messaging is InOnly.

+ +
+
// expose a echo websocket client, that sends back an echo
+from("websocket://echo")
+    .log(">>> Message received from WebSocket Client : ${body}")
+    .transform().simple("${body}${body}")
+    // send back to the client, by sending the message to the same endpoint
+    // this is needed as by default messages is InOnly
+    // and we will by default send back to the current client using the provided connection key
+    .to("websocket://echo");
+
+
+ +

This example is part of an unit test, which you can find here. As a client we use the AHC library which offers support for web socket as well.

+ +

See Also

+ + + +
+
+ +
+ + +
+
+
+
+
+
+ +
+
+
+© 2004-2011 The Apache Software Foundation. +
+Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. +
+Graphic Design By Hiram +
+ + + + + + + +