Introduction to streams and stream networks
A stream query is part of a
stream network. A stream network starts with one or more
stream source templates (see
Creating streams from event templates). A stream source template collects matching events received by the monitor instance and places them as items in a stream. Stream queries (see
Defining stream queries) take existing streams (a stream created by a stream source template or by another stream query) and generate added-value streams that contain derived items. Finally,
stream listeners (see
Using output from streams) bring items out of the stream network and into procedural code. In a given stream network, upstream elements feed into downstream elements to generate derived items.
When a monitor instance receives an event that matches a stream source template the correlator activates the stream network. The passage of time can also cause the correlator to activate a stream network. If, for example, a stream query operates on the items received within the last 5.0 seconds, then 5.0 seconds after an item arrives the correlator will again activate the stream network (see
Adding window definitions to from and join clauses).
In a given stream network activation, not all stream queries and not all stream listeners necessarily receive items. Which queries and stream listeners receive items depends on the definitions of the stream queries and stream listeners. However, in a given stream network activation, the correlator passes items through all queries and stream listeners in the network that receive items. A query or stream listener that receives an item is considered to be activated. Only when processing of all activated queries and stream listeners is complete does the correlator process the next event on the context's input queue.
In a given stream network activation, various queries can produce multiple items on their output streams. The items in a particular stream during a particular stream network activation are called a
lot. If a stream query or stream listener receives a lot that contains multiple items, it processes all items as part of a single stream network activation (see
Working with lots that contain multiple items, and
Coassigning to sequences in stream listeners).
The items in a lot are always ordered, and the lots themselves are always ordered.