public IntegrationEvent(IntegrationEventBase @event) { EventId = @event.Id; CreationTime = DateTime.UtcNow; EventTypeName = @event.GetType().FullName; Content = JsonConvert.SerializeObject(@event); State = EventStateEnum.NotSend; TimesSent = 0; }
public void Publish(IntegrationEventBase @event) { EnsureConnected(); using (var publisherChannel = _persistentRabbitMqConnection.CreateChannel()) { var eventType = @event.GetType().Name; var message = JsonConvert.SerializeObject(@event); var messageBody = Encoding.UTF8.GetBytes(message); publisherChannel.BasicPublish( exchange: _rabbitMqConfig.ExchangeName, routingKey: eventType, mandatory: true, body: messageBody); } }