/// <summary> /// Creates an instance of <c>TacitusLogger.Destinations.RabbitMq.RabbitMqDestination</c> using all its dependencies. /// </summary> /// <param name="rabbitMqConnection">RabbitMQ connection that will be used to publish messages.</param> /// <param name="messagePublisher">An implementation of <c>TacitusLogger.Destinations.RabbitMq.Publishers.IMessagePublisher</c> that encapsulates the publishing logic.</param> /// <param name="publicationAddressProvider">An implementation of <c>TacitusLogger.Destinations.RabbitMq.PublicationAddressProviders.IPublicationAddressProvider</c> that provides the publication address.</param> /// <param name="logSerializer">Log model serializer.</param> public RabbitMqDestination(IConnection rabbitMqConnection, IPublicationAddressProvider publicationAddressProvider, ILogSerializer logSerializer, IMessagePublisher messagePublisher) { _rabbitMqConnection = rabbitMqConnection ?? throw new ArgumentNullException("rabbitMqConnection"); _messagePublisher = messagePublisher ?? throw new ArgumentNullException("messagePublisher"); _publicationAddressProvider = publicationAddressProvider ?? throw new ArgumentNullException("publicationAddressProvider"); _logSerializer = logSerializer ?? throw new ArgumentNullException("logSerializer"); }
/// <summary> /// Adds the publication address provider of type <c>TacitusLogger.Destinations.RabbitMq.IPublicationAddressProvider</c> that is used /// by RabbitMQ destination to get publication addresses of type <c>RabbitMQ.Client.PublicationAddress</c>. /// </summary> /// <param name="publicationAddressProvider">The publication address provider.</param> /// <returns>Self.</returns> public IRabbitMqDestinationBuilder WithAddress(IPublicationAddressProvider publicationAddressProvider) { if (_publicationAddressProvider != null) { throw new InvalidOperationException("Publication address provider has already been set during this build"); } _publicationAddressProvider = publicationAddressProvider ?? throw new ArgumentNullException("publicationAddressProvider"); return(this); }
/// <summary> /// Creates an instance of <c>TacitusLogger.Destinations.RabbitMq.RabbitMqDestination</c> using /// <c>TacitusLogger.Destinations.RabbitMq.Publishers.BasicMessagePublisher</c> as a default message publisher /// and <c>JsonLogSerializer</c> as a default log data serializer. /// </summary> /// <param name="rabbitMqConnection"></param> /// <param name="publicationAddressProvider"></param> public RabbitMqDestination(IConnection rabbitMqConnection, IPublicationAddressProvider publicationAddressProvider) : this(rabbitMqConnection, publicationAddressProvider, new JsonLogSerializer(), new BasicMessagePublisher()) { }