public void Handle(IEvent message)
        {
            var dispatchContexts = eventPublishers
                                   .Where(p => p.Handles(message))
                                   .Select(p => p.CreateDispatchContext(message));

            using (var session = store.OpenSession())
            {
                foreach (var dispatchContext in dispatchContexts)
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug("Storing dispatch request.");
                    }
                    var dispatchRequest = new ExternalIntegrationDispatchRequest
                    {
                        Id = $"ExternalIntegrationDispatchRequests/{Guid.NewGuid()}",
                        DispatchContext = dispatchContext
                    };

                    session.Store(dispatchRequest);
                }

                session.SaveChanges();
            }
        }
        public async Task Handle(IDomainEvent message)
        {
            var dispatchContexts = eventPublishers
                                   .Where(p => p.Handles(message))
                                   .Select(p => p.CreateDispatchContext(message))
                                   .ToArray();

            if (dispatchContexts.Length == 0)
            {
                return;
            }

            using (var session = store.OpenAsyncSession())
            {
                foreach (var dispatchContext in dispatchContexts)
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug("Storing dispatch request.");
                    }

                    var dispatchRequest = new ExternalIntegrationDispatchRequest
                    {
                        Id = $"ExternalIntegrationDispatchRequests/{Guid.NewGuid()}",
                        DispatchContext = dispatchContext
                    };

                    await session.StoreAsync(dispatchRequest)
                    .ConfigureAwait(false);
                }

                await session.SaveChangesAsync()
                .ConfigureAwait(false);
            }
        }
        public void Handle(IEvent message)
        {
            var dispatchContexts = EventPublishers
                                   .Where(p => p.Handles(message))
                                   .Select(p => p.CreateDispatchContext(message));

            foreach (var dispatchContext in dispatchContexts)
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.DebugFormat("Storing dispatch request.");
                }
                var dispatchRequest = new ExternalIntegrationDispatchRequest
                {
                    DispatchContext = dispatchContext
                };
                Session.Store(dispatchRequest);
            }
        }