Specifying the Event Processing Order

Notification Services provides two options for determining how application rules are processed. You can specify whether rules are fired once per generator quantum period or every time an event batch arrives. These two options are known as quantum sequencing and sub-quantum sequencing, respectively. These two options provide a choice between strict data correctness and generator performance. By default, Notification Services uses quantum sequencing. For more information about generator quanta, see Specifying the Generator Quantum Duration.

Quantum Sequencing

In this mode, Notification Services fires rules once per generator quantum in the following order:

  1. Event chronicle rules
  2. Event-driven subscription rules
  3. Scheduled subscription rules

If multiple event batches arrive during the quantum, Notification Services processes the event chronicle rules and event-driven subscription rules against all of those event batches at one time, as if all events were part of the same batch.

All scheduled subscriptions to be processed during the quantum are processed at one time at the end of the quantum period.

By grouping all events that arrived during the quantum and all scheduled subscriptions due during the quantum, the application can realize significant performance gains from batching. However, this performance benefit is at the expense of strict ordering correctness. If ordering correctness is not a strict requirement for your application, use quantum sequencing.

Sub-Quantum Sequencing

In some cases, you need to ensure that all event batches are processed individually and in the order the batches were received, and that scheduled subscriptions only use the data that arrived before the scheduled subscription was due to be processed. In this case, you need to use sub-quantum sequencing.

Sub-quantum sequencing processes events and subscriptions as follows:

  1. Before processing the first event batch, Notification Services fires scheduled rules for the scheduled subscriptions that were due to be processed before the first event batch arrived.
  2. Notification Services then fires rules for each event batch in the order of arrival:
    1. Event chronicle rules
    2. Event-driven subscription rules
    3. Scheduled subscription rules

After all event batches are processed, Notification Services fires scheduled subscription rules for any subscriptions due to be processed after the arrival of the last event batch.

Quantum and Sub-Quantum Sequencing Illustrated

The following illustration shows eight generator quanta. During these eight generator quanta, 12 event batches arrive and 12 scheduled subscriptions are due to be processed.

How quantum sequencing works

Example event and subscription timeline

The generator processes the 12 event batches and 12 scheduled subscriptions differently depending on the specified event processing order. The following table shows how the generator processes each quantum.

Quantum Quantum sequencing Sub-quantum sequencing

Process quantum 1

Event batches E1, E2, and E3 are processed together.

No scheduled (timed) subscriptions to process.

Event batches E1, E2, and E3 are processed sequentially.

No scheduled (timed) subscriptions to process.

Process quantum 2

Event batches E4 and E5 are processed together.

Scheduled subscription T1 is processed.

Event batches E4 and E5 are processed sequentially.

Scheduled subscription T1 is processed.

Process quantum 3

Event batches E6 and E7 are processed together.

Scheduled subscription T2 is processed.

Event batch E6 is processed.

Scheduled subscription T2 is processed.

Event batch E7 is processed.

Process quantum 4

Event batch E8 is processed.

Scheduled subscriptions T3 and T4 are processed together.

Event batch E8 is processed.

Scheduled subscriptions T3 and T4 are processed together.

Process quantum 5

Event batches E9 and E10 are processed together.

Scheduled subscription T5 is processed.

Scheduled subscription T5 is processed.

Event batches E9 and E10 are processed sequentially.

Process quantum 6

Event batch E11 is processed.

Scheduled subscriptions T6 and T7 are processed together.

Scheduled subscription T6 is processed.

Event batch E11 is processed.

Scheduled subscription T7 is processed.

Process quantum 7

Event batch E12 is processed.

Scheduled subscriptions T8 and T9 are processed together.

Scheduled subscriptions T8 and T9 are processed together.

Event batch E12 is processed.

Process quantum 8

There are no event batches to process.

Scheduled subscriptions T10, T11, and T12 are processed together.

There are no event batches to process.

Scheduled subscriptions T10, T11, and T12 are processed together.

Configuring Quantum or Sub-Quantum Sequencing

To configure sub-quantum sequencing, you set the ProcessEventsInOrder property to true. Quantum sequencing is the default, so you can either set the ProcessEventsInOrder property to false, or you can exclude the property from your application definition.

To configure quantum or sub-quantum sequencing

See Also

Concepts

Specifying Application Execution Settings
Specifying the Generator Quantum Duration
Defining Event Chronicle Rules
Defining Subscription Rules
Defining Event Rules
Defining Scheduled Rules

Help and Information

Getting SQL Server 2005 Assistance