Publishing and Subscribing

Messages are written to a stream and then read from that stream.

When a message is written to a stream, we call that "publishing". The publisher may be a CCL query, which writes the output of the query, or an adapter, which gets data from an external data source and then writes that data to the stream.

When a query or adapter connects to a stream to read the messages sent on that stream, we call that "subscribing".

Each stream may have zero or more subscribers. Each subscriber to a stream receives a copy of all messages sent to that stream from the time that the subscriber subscribes to the stream until the time that the subscriber unsubscribes. Unless the Guaranteed Delivery feature is used, messages published before the subscriber subscribed are not sent to the subscriber.

Each stream may have zero or more publishers. If there are multiple publishers, and if the publishers specify the row timestamps in the rows, then the rows need to be synchronized, in other words, arrive at the stream's destination in the proper order. There are at least two ways to do this. If the publishers synchronize with each other, they can simply insert the rows in the proper order. If the publishers do not synchronize with each other, set the appropriate stream properties ("Maximum Delay", "Messages can come out of order", and "Maximum out of order delay") to tell the Sybase CEP Server to sort the incoming messages and process them in order.

Note that synchronization applies both within a stream (if there are multiple publishers to that stream) and across multiple streams.

For more information about stream synchronization and out-of-order messages, see the Sybase CEP Programmer's Guide .

The most common way to publish or subscribe to a stream is to create an adapter using one of the Sybase CEP SDKs.

It is possible to use the URI to publish directly or subscribe directly to a stream over the network without using an adapter. See Connecting to Streams over a Network.

Note that you can only read and write to a stream while the project (query module) that contains it is running.