private Observation SubscribeForAction(DurableJobQueueActionType filterType, Action < ObservableDurableJobQueue <TQueue, TQueuePoison>, TQueue, TQueuePoison> actions) { var observation = new Observation() { Input = Fixture.CreateAnonymous <TQueue>(), Poison = Fixture.CreateAnonymous <TQueuePoison>() }; using (var store = JobStorageFactory()) using (var fired = new ManualResetEventSlim(false)) using (var subscription = store.OnQueueAction.Subscribe(a => { if (a.ActionType == filterType) { observation.Action = a; fired.Set(); } })) { actions(store, observation.Input, observation.Poison); fired.Wait(TimeSpan.FromSeconds(2)); return(observation); } }
internal DurableJobQueueAction(DurableJobQueueActionType actionType, TQueue input, TQueuePoison poison) { ActionType = actionType; Input = input; Poison = poison; switch (actionType) { case DurableJobQueueActionType.Queued: case DurableJobQueueActionType.Completed: case DurableJobQueueActionType.Pending: default: if (!_isInputValueType && null == input) { throw new ArgumentNullException("input"); } if (!_isPoisonValueType && null != poison) { throw new ArgumentException("must be null", "poison"); } break; case DurableJobQueueActionType.Deleted: if (!_isInputValueType && null != input) { throw new ArgumentException("must be null", "input"); } if (!_isPoisonValueType && null == poison) { throw new ArgumentNullException("poison"); } break; case DurableJobQueueActionType.Poisoned: if (!_isInputValueType && null == input) { throw new ArgumentNullException("input"); } if (!_isPoisonValueType && null == poison) { throw new ArgumentNullException("poison"); } break; } }
private CallCount GetOnQueueActionCallCount(DurableJobQueueActionType filter, int maxConcurrent, int jobsToCreate, int releaseAfterJobCountStateChanged) { var scheduler = new HistoricalScheduler(); var queuedEvent = new ManualResetEventSlim(false); var callCount = new CallCount() { MonitoredQueue = _monitoredJobQueueFactory(scheduler, _durableQueueFactory), }; callCount.MonitoredQueue.MaxConcurrent = maxConcurrent; using (var subscription = callCount.MonitoredQueue.OnQueueAction .Subscribe(action => { if (action.ActionType == filter) { ++callCount.Actual; if (callCount.Actual == releaseAfterJobCountStateChanged) { queuedEvent.Set(); } //else if (callCount.Actual == callCount.MonitoredQueue.MaxQueueItemsToPublishPerInterval) // queuedEvent.Set(); } })) { foreach (var input in _fixture.CreateMany <TInput>(jobsToCreate)) { callCount.MonitoredQueue.AddJob(input); } scheduler.AdvanceBy(callCount.MonitoredQueue.PollingInterval.Add(TimeSpan.FromSeconds(1))); queuedEvent.Wait(TimeSpan.FromSeconds(5)); return(callCount); } }