none
SI 2.1: Access to events in the stream

    Question

  • Hello Sorry for my bad English. How can I get access to events that are already in the stream. I want to keep the event in the stream for a long time. Then I want to get access to events in the stream that are there.
    Saturday, June 22, 2013 7:50 AM

All replies

  • To keep them in the stream for a while, you would use AlterEventDuration.

    To access them ... I'm not sure what you mean by this but I'll try to give it a shot ...

    1) Use a LINQ query over the events after altering the duration.

    2) Use a UDO/UDA ... this will give you all of the events in a particular window.

    3) Output Adapter/Sink ... events are sent to the output adapter/sink and you can access them there.

    It depends on what you are trying to do. Typically, altering your duration and then writing a LINQ query will do what you want.


    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)


    Ruminations of J.net


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    Saturday, June 22, 2013 11:00 AM

  • IQStreamable<int> inputStream = application.DefineObservable(() => Observable.Range(0, 2)).ToPointStreamable(r => PointEvent<int>.CreateInsert(DateTime.UtcNow, r), AdvanceTimeSettings.StrictlyIncreasingStartTime); var oneDay = inputStream.AlterEventDuration(e => TimeSpan.FromDays(1)); var outSink = from t in oneDay select t; var mySink = application.DefineObserver(() => Observer.Create<int>(x => Console.WriteLine("Out: {0}", x))); mySink.Deploy("serverSink"); var proc = outSink.Bind(mySink).Run("serverProcess");

    I tried to do it but did not work. When recalling the events are removed from the stream:

    foreach (var outS in outSink.ToEnumerable())
    {
       Console.WriteLine("Out: {0}", outS);
    }

    Out: 0
    Out: 1


    Saturday, June 22, 2013 12:07 PM
  • Can you please describe your use case and what you are trying to do here?

    Since you are getting output, your stream is running. And yes, once they are output, they are out of the stream. Since you are using StrictlyIncreasingStartTime, when your Observable completes, it sends a DateTimeOffset of MaxValue ... clearing the stream out. If you write out your CTIs by using Observer.Create<IntervalEvent<int>>, you'll see the CTIs as well. Just make sure that you check the EventKind before trying to access the payload; CTIs won't have a payload.


    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)


    Ruminations of J.net


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    Monday, June 24, 2013 2:30 PM
  • I'll explain what I want to do. Every second I get a few thousand events. Each new event is checked every existing event. Thereafter, the event is in the flow or removed from the stream. After that comes a new event ... And so on.
    I want to keep the existing events in the stream and have access to them in a few hours, days, weeks.



    • Edited by apor Monday, July 08, 2013 6:38 AM 1548
    Monday, July 08, 2013 6:34 AM
  • What you are trying to do is accomplished using your queries and by altering the temporal header of the events. You're not going to access the events in the stream as you would with a traditional database ... for example, issue the query and then loop over them. It doesn't work that way. Instead, the queries execute constantly against the events that are still valid in the application timeline based on the temporal headers.

    You can manipulate the temporal headers ... and thus keep events "alive" in the stream for your queries ... using several different methods (see http://msdn.microsoft.com/en-us/library/ee362414(v=sql.111).aspx). For example, if you want an event to "live" in the stream for the next hour, you would use:

    // set event duration to 1 hour.
    var onehour = inputStream.AlterEventDuration(e => TimeSpan.FromHours(1));
    


    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)


    Ruminations of J.net


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    Monday, July 08, 2013 3:32 PM