public void Enqueue(IEngineTask task) { _loggingAdapter.WriteEntry(new LogEntry(LoggingEventType.Information, "Enqueuing task: {task}", new Dictionary <string, object>() { { "task", JsonConvert.SerializeObject(task) } })); Queue.Enqueue(task); }
private async Task InvokeAction(IEngineTask task) { try { var taskHandler = _taskHandlerFactory(task.GetType().Name); await taskHandler.ProcessActionTask(task); } catch (Exception e) { // global exception handler for tasks _loggingAdapter.WriteEntry(new LogEntry(LoggingEventType.Error, "We threw an exception! {exception}", new Dictionary <string, object>() { { "exception", e }, })); _eventQueue.PublishEvent(new EventNotification() { ProcessId = (task as IProcessEngineTask)?.ProcessId, ProcessItemId = (task as IProcessItemEngineTask)?.ProcessItemId, ActionId = (task as IActionTask)?.ActionId, PrincipalId = task.PrincipalId, NotificationKind = EventNotificationKinds.Exception, Exception = e }); } }
public TestWorkflowEngineEventQueue(ILoggingAdapter loggingAdapter) { _loggingAdapter = loggingAdapter; _loggingAdapter.WriteEntry(new LogEntry(LoggingEventType.Information, "Test Event Queue created")); _notifications = new List <EventNotification>(); _subscriptions = new List <EventSubscription>(); }
public void StoreUnsavedMutations(IProcessItemEventContainer processItem, MutationStoredCallback callback) { string lastProcessItemMutationId = null; var lastMutationDateTimeUtc = DateTime.MinValue; _loggingAdapter.WriteEntry(new LogEntry(LoggingEventType.Information, "Storing mutations: {mutations}", new Dictionary <string, object>() { { "mutations", JsonConvert.SerializeObject(processItem.UnsavedMutations) } })); while (processItem.UnsavedMutations.Any()) { _eventStreamsLock.EnterWriteLock(); _eventStreams.Add(new ProcessItemEvent() { MutationId = lastProcessItemMutationId = Guid.NewGuid().ToString(), MutationTimestampUtc = lastMutationDateTimeUtc = DateTime.UtcNow, ProcessItemId = processItem.ProcessItemId, Mutation = processItem.UnsavedMutations.Dequeue(), }); _eventStreamsLock.ExitWriteLock(); } callback?.Invoke(lastProcessItemMutationId, lastMutationDateTimeUtc); }
public void PublishEvent(EventNotification notification) { _notifications.Add(notification); _loggingAdapter.WriteEntry(new LogEntry(LoggingEventType.Information, "New event published. {notification}", new Dictionary <string, object>() { { "notification", JsonConvert.SerializeObject(notification) }, { "processItemId", notification.ProcessItemId } })); }