public Task ClearAsync()
        {
            if ((supportedMethod & Method.Clear) == Method.Clear)
            {
                return(publishingStore.ClearAsync());
            }

            return(Async.CompletedTask);
        }
        /// <summary>
        /// Re-publishes events from unpublished queue.
        /// Uses <paramref name="formatter"/> to deserialize events from store.
        /// </summary>
        /// <param name="formatter">The event deserializer.</param>
        /// <returns>The continuation task.</returns>
        public async Task RecoverAsync(IDeserializer formatter)
        {
            IEnumerable <EventPublishingModel> models = await store.GetAsync();

            foreach (EventPublishingModel model in models)
            {
                IEvent eventModel = formatter.DeserializeEvent(Type.GetType(model.Event.EventKey.Type), model.Event.Payload);
                await RecoverEventAsync(eventModel, model.PublishedHandlerIdentifiers);
            }

            await store.ClearAsync();
        }
Example #3
0
        /// <summary>
        /// Re-publishes events from unpublished queue.
        /// Uses <paramref name="formatter"/> to deserialize events from store.
        /// </summary>
        /// <param name="formatter">The event deserializer.</param>
        /// <returns>The continuation task.</returns>
        public async Task RecoverAsync(IDeserializer formatter)
        {
            Ensure.NotNull(formatter, "formatter");

            log.Debug("Starting recovery.");

            IEnumerable <EventPublishingModel> models = await store.GetAsync();

            foreach (EventPublishingModel model in models)
            {
                IEvent eventModel = formatter.DeserializeEvent(Type.GetType(model.Event.EventKey.Type), model.Event.Payload);

                log.Debug(eventModel, "Recovering an event.");
                await RecoverEventAsync(eventModel, model.PublishedHandlerIdentifiers);
            }

            await store.ClearAsync();

            log.Debug("Recovery finished.");
        }