public async Task MarkEventAsPublishedAsync(Guid eventId)
        {
            Guard.Requires(eventId, nameof(eventId)).IsNotEqualTo(Guid.Empty);

            var integrationEvent = repository.GetAll().First(e => e.EventId == eventId);

            if (integrationEvent.State == IntegrationEventState.ReadyToPublish)
            {
                integrationEvent.State = IntegrationEventState.Published;

                await repository.UpdateAsync(integrationEvent.Id, integrationEvent);
            }
        }
Beispiel #2
0
        private async Task ProccessEvents()
        {
            List <IntegrationEventLog> localIntegrationEvents = await _integrationEventLogRepository.GetAllReadyToPulishAndUpdateTheirStatuses();

            foreach (var @event in localIntegrationEvents)
            {
                object obj       = @event.Content.DeserializeJson();
                var    messageId = @event.MessageId;

                await _endpoint.Publish(obj, messageId).ConfigureAwait(false);

                @event.State = EventStateEnum.Published;
                await _integrationEventLogRepository.UpdateAsync(@event);

                await _integrationEventLogRepository.UnitOfWork.SaveChangesAsync();
            }
        }