none
Handling events sampling to 1 sec

    Question

  • I get an update event at the rate of 150-200 updates / second. I would like to conflate this to 1 second per key.

    Example: In 1 second I receive updates for 3 keys A,B,C in the order of: A1, B1, C1, A2, A3, B2

    I would like to handle this update every 1 second & process only A3, B2 & C1 from the above example.

    How do I go about with this using Reactive extension? So far I tried:

    Observable.FromEventPattern<EventArgs>(_listener, "EventsToBeProcessed", System.Reactive.Concurrency.NewThreadScheduler.Default)
                .GroupBy(x => x.EventArgs.Key)
                .Subscribe(g =>
                {
                    g.Sample(TimeSpan.FromSeconds(1))
                    .Subscribe(x1 =>
                    {
                        updateSubject.OnNext(x1.EventArgs.NewValue);
                    });
                });
    
    updateSubject
    .SubscribeOn(NewThreadScheduler.Default)
    .ObserveOn(NewThreadScheduler.Default)
    .Subscribe(EventsToBeProcessed);
    This does not seem to help. Please suggest the right approach for this.

    Wednesday, July 19, 2017 8:38 PM