The cometd: component is a transport for working with the jetty implementation of the cometd/bayeux protocol.
Using this component in combination with the dojo toolkit library it's possible to push Camel messages directly into the browser using an AJAX based mechanism.
Maven users will need to add the following dependency to their
pom.xml for this component:
The channelName represents a topic that can be subscribed to by the Camel endpoints.
cometds: represents an SSL configured endpoint.
See this blog entry by David Greco who contributed this component to Apache Camel, for a full sample.
The root directory for the web resources or classpath. Use the protocol file: or classpath: depending if you want that the component loads the resource from file system or classpath. Classpath is required for OSGI deployment where the resources are packaged in the jar. Notice this option has been renamed to
baseResource from Camel 2.7 onwards.
Camel 2.7: The root directory for the web resources or classpath. Use the protocol file: or classpath: depending if you want that the component loads the resource from file system or classpath. Classpath is required for OSGI deployment where the resources are packaged in the jar
The server side poll timeout in milliseconds. This is how long the server will hold a reconnect request before responding.
The client side poll timeout in milliseconds. How long a client will wait between reconnects
The max client side poll timeout in milliseconds. A client will be removed if a connection is not received in this time.
The client side poll timeout, if multiple connections are detected from the same browser.
true, the server will accept JSON wrapped in a comment and will generate JSON wrapped in a comment. This is a defence against Ajax Hijacking.
Camel 2.9: Reference to a
org.apache.camel.util.jsse.SSLContextParameters in the Registry. This reference overrides any configured SSLContextParameters at the component level. See Using the JSSE Configuration Utility.
Camel 2.10: If
true, the server will support for cross-domain filtering
Camel 2.10: The origins domain that support to cross, if the
Camel 2.10: The filterPath will be used by the CrossOriginFilter, if the
Camel 2.10.5/2.11.1: (Producer only): Whether to disconnect local sessions after publishing a message to its channel. Disconnecting local session is needed as they are not swept by default by CometD, and therefore you can run out of memory.
You can append query options to the URI in the following format,
Here is some examples on How to pass the parameters
For file (for webapp resources located in the Web Application directory --> cometd://localhost:8080?resourceBase=file./webapp
For classpath (when by example the web resources are packaged inside the webapp folder --> cometd://localhost:8080?resourceBase=classpath:webapp
Available as of Camel 2.8
You can configure custom
Extension's to the
CometdComponent which allows you to use authentication as documented here
Setting up SSL for Cometd Component
Using the JSSE Configuration Utility
As of Camel 2.9, the Cometd component supports SSL/TLS configuration through the Camel JSSE Configuration Utility. This utility greatly decreases the amount of component specific code you need to write and is configurable at the endpoint and component levels. The following examples demonstrate how to use the utility with the Cometd component.
Programmatic configuration of the component
Spring DSL based configuration of endpoint