The primary purpose of Bayeux is to support responsive bidirectional interactions between web clients using Ajax and the web server.
Bayeux is a protocol for transporting asynchronous messages (primarily over HTTP), with low latency between a web server and a web client.
The messages are routed via named channels and can be delivered:
By default, publish/subscribe routing semantics are applied to the channels.
Delivery of asynchronous messages from the server to a web client is often described as "server-push".
The combination of server push techniques with an Ajax web application has been called "Comet".
CometD is a project by the Dojo Foundation to provide multiple implementation of the Bayeux protocol in several programming languages.
The Bayeux protocol seeks to reduce the complexity of developing Comet applications by allowing implementors to more easily interoperate, to solve common message distribution and routing problems, and to provide mechanisms for incremental improvements and extensions.
You may want to read the Bayeux Specification.
Channels are identified by names that are styled as the absolute path component
of a URI without parameters as defined by RFC2396:
channel_name = "/" channel_segments channel_segments = channel_segment *( "/" channel_segment ) channel_segment = token
The channel name consists of an initial "/" followed by an optional sequence of
path segments separated by a single slash "/" character. Within a path segment,
the character "/" is reserved.
Example non-meta channel names are:
/foo /foo/bar /foo-bar/(foobar) /some/channel
Channels are by default broadcast publish subscribe, so that all subscribers will see all messages published to the channel on the server.
Messages may be privately delivered to a specific client + channel combination and bypass any default routing.
Channels starting with /meta/ are reserved for the use of the protocol (eg /meta/handshake)
Channels starting with /service are server only publish/subscribe. Messages published to /service channels will only be delivered to server side clients.
Messages may still be explicitly delivered to a client on a /service channel
A set of channels may be specified with a channel globbing pattern:
channel_pattern = *( "/" channel_segment ) "/" wild_card wild_card = "*" | "**"
The channel patterns support only trailing wildcards of either "*" to match a
single segment or "**" to match multiple segments. Example channel patterns
are:
xxxx
Bayeux messages:
A simple Bayeux message could be specified as:
{channel:"/some/channel",data:[1,2,3]}
This message has a natural instantiation in Javascript. The message could be transported as a wire format that uses the JSON as described above, or the instantiated Javascript objects could be serialized to XML if some transport wished. If delivered to a Java Bayeux implementation, then the message would be instantiated as a java.util.Map<String,Object> instance that contained java.lang.String keys and values of type java.lang.String and java.util.Array<Object>.
All fields in the top level of a JSON message are reserved for the use of the protocol. The following fields are the most important defined fields: