public override async Task OnActivateAsync() { streamProvider = GetStreamProvider("SMSProvider"); jobManager = GrainFactory.GetGrain <IJobManagerGrain>(0, "JobManager"); delay = await jobManager.GetDelay(); // ask the JobManager which streams it should subscribe var subscribe = await jobManager.GetSubscribe(this.GetPrimaryKey()); foreach (var streamID in subscribe) { var stream = streamProvider.GetStream <string>(streamID, null); // To resume stream in case of stream deactivation var subscriptionHandles = await stream.GetAllSubscriptionHandles(); if (subscriptionHandles.Count > 0) { foreach (var subscriptionHandle in subscriptionHandles) { await subscriptionHandle.ResumeAsync(Process); } } // explicitly subscribe to a stream await stream.SubscribeAsync(Process); } }
public override async Task OnActivateAsync() { streamProvider = GetStreamProvider("SMSProvider"); jobManager = GrainFactory.GetGrain <IJobManagerGrain>(0, "JobManager"); var window = await jobManager.GetWindow(this.GetPrimaryKey()); window_length = window.Item1; window_slide = window.Item2; func = new WindowFunction(window_length, window_slide); // ask the JobManager which streams it should subscribe var subscribe = await jobManager.GetSubscribe(this.GetPrimaryKey()); foreach (var streamID in subscribe) { var stream = streamProvider.GetStream <MyType>(streamID, null); // To resume stream in case of stream deactivation var subscriptionHandles = await stream.GetAllSubscriptionHandles(); if (subscriptionHandles.Count > 0) { foreach (var subscriptionHandle in subscriptionHandles) { await subscriptionHandle.ResumeAsync(Process); } } // explicitly subscribe to a stream await stream.SubscribeAsync(Process); } }
public override async Task OnActivateAsync() { List <Task> t = new List <Task>(); streamProvider = GetStreamProvider("SMSProvider"); jobManager = GrainFactory.GetGrain <IJobManagerGrain>(0, "JobManager"); var window = await jobManager.GetWindow(this.GetPrimaryKey()); window_length = window.Item1; window_slide = window.Item2; data1 = new SortedList <long, List <MyType> >(); data2 = new SortedList <long, List <MyType> >(); func1 = new WindowFunction(window_length, window_slide); func2 = new WindowFunction(window_length, window_slide); // ask the JobManager which streams it should subscribe var subscribe = await jobManager.GetTwoSourceSubscribe(this.GetPrimaryKey()); /********** Handle the first source stream*************************/ var stream1 = streamProvider.GetStream <MyType>(subscribe.Item1, null); var subscriptionHandles1 = await stream1.GetAllSubscriptionHandles(); if (subscriptionHandles1.Count > 0) { foreach (var subscriptionHandle in subscriptionHandles1) { await subscriptionHandle.ResumeAsync(Process1); } } t.Add(stream1.SubscribeAsync(Process1)); /********** Handle the second source stream************************/ var stream2 = streamProvider.GetStream <MyType>(subscribe.Item2, null); var subscriptionHandles2 = await stream2.GetAllSubscriptionHandles(); if (subscriptionHandles2.Count > 0) { foreach (var subscriptionHandle in subscriptionHandles2) { await subscriptionHandle.ResumeAsync(Process2); } } t.Add(stream2.SubscribeAsync(Process2)); await Task.WhenAll(t); }