THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

The Bit Bucket (Greg Low): IDisposable

Ramblings of Greg Low (SQL Server MVP, MCM and Microsoft RD) - SQL Down Under

SQL Server 2008 R2 - StreamInsight - Event Payloads

One of the key decisions you'll make when working with StreamInsight is the payload that will be carried by each event. Events contain and EventKind (which is related to whether they're inserting a new event or modifying an existing one), some temporal information (depending upon the EventShape -> Point, Interval or Edge) and a payload that is user-defined.

A payload is defined via a .NET class or struct. In general, a class will be a better option as it ensures field ordering which is likely to be important for generic (vs typed) adapters. StreamInsight ignores anything except public fields and properties and there are limitations on the data types. For example, basic .NET types are permitted but not any of the nested types.

A payload will typically look like:

public class TollPayload

{

    public int TollBoothID { get; set; }

    public int LaneID { get; set; }

    public int VehicleType { get; set; }

    public String TagID { get; set; }

}

In addition to the fields and properties, I'd suggest a few other items are helpful.

First, make sure you override the ToString() method. It's helpful to be able to just show the contents of an event as a string without needing to couple the consumer's code to the payload fields. This is particularly useful with logging.

Second, I find it useful to provide public static methods that convert types (or enums) to much more meaningful names. In particular, this can be useful while projecting the event fields in the LINQ standing queries.

Published Saturday, January 16, 2010 1:35 PM by Greg Low

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(required) 
Submit

This Blog

Syndication

Tags

No tags have been created or used yet.
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement