The rabbit bus.
Inheritance: AbstractBus, IBusAdvanced, IChannelProvider
コード例 #1
0
ファイル: RabbitReceiver.cs プロジェクト: Sliborskii/Contour
 /// <summary>
 /// Initializes a new instance of the <see cref="RabbitReceiver"/> class.
 /// </summary>
 /// <param name="bus">A reference to the bus containing the receiver</param>
 /// <param name="configuration">
 /// The configuration.
 /// </param>
 /// <param name="connectionPool">
 /// A bus connection pool
 /// </param>
 public RabbitReceiver(RabbitBus bus, IReceiverConfiguration configuration, IConnectionPool <IRabbitConnection> connectionPool)
     : base(configuration)
 {
     this.bus             = bus;
     this.connectionPool  = connectionPool;
     this.receiverOptions = (RabbitReceiverOptions)configuration.Options;
     this.logger          = LogManager.GetLogger($"{this.GetType().FullName}(Endpoint=\"{this.bus.Endpoint}\")");
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RabbitSender"/> class.
        /// </summary>
        /// <param name="bus">
        /// A reference to the bus containing the sender
        /// </param>
        /// <param name="configuration">
        /// Конфигурация отправителя сообщений.
        /// </param>
        /// <param name="connectionPool">
        /// A bus connection pool
        /// </param>
        /// <param name="filters">
        /// Фильтры сообщений.
        /// </param>
        public RabbitSender(RabbitBus bus, ISenderConfiguration configuration, IConnectionPool <IRabbitConnection> connectionPool, IEnumerable <IMessageExchangeFilter> filters, IDictionary <Type, IMessageExchangeFilterDecorator> filterDecorators = null)
            : base(bus.Endpoint, configuration, filters, filterDecorators)
        {
            this.bus            = bus;
            this.connectionPool = connectionPool;
            this.senderOptions  = (RabbitSenderOptions)this.Configuration.Options;

            this.logger = LogManager.GetLogger($"{this.GetType().FullName}({this.bus.Endpoint}, {this.Configuration.Label})");
        }
コード例 #3
0
ファイル: RabbitSender.cs プロジェクト: Sliborskii/Contour
        /// <summary>
        /// Initializes a new instance of the <see cref="RabbitSender"/> class.
        /// </summary>
        /// <param name="bus">
        /// A reference to the bus containing the sender
        /// </param>
        /// <param name="configuration">
        /// Конфигурация отправителя сообщений.
        /// </param>
        /// <param name="connectionPool">
        /// A bus connection pool
        /// </param>
        /// <param name="filters">
        /// Фильтры сообщений.
        /// </param>
        public RabbitSender(RabbitBus bus, ISenderConfiguration configuration, IConnectionPool <IRabbitConnection> connectionPool, IEnumerable <IMessageExchangeFilter> filters)
            : base(bus.Endpoint, configuration, filters)
        {
            this.bus            = bus;
            this.connectionPool = connectionPool;
            this.senderOptions  = (RabbitSenderOptions)this.Configuration.Options;

            this.logger = LogManager.GetLogger($"{this.GetType().FullName}(Endpoint=\"{this.bus.Endpoint}\")");
        }
コード例 #4
0
ファイル: RabbitChannel.cs プロジェクト: ehramovich/Contour
        /// <summary>
        /// »нициализирует новый экземпл¤р класса <see cref="RabbitChannel"/>.
        /// </summary>
        /// <param name="bus">
        /// The bus.
        /// </param>
        /// <param name="native">
        /// The native.
        /// </param>
        public RabbitChannel(RabbitBus bus, IModel native)
        {
            this.bus    = bus;
            this.Native = native;

            Logger.TraceFormat("Channel is opened.");

            this.Native.ModelShutdown += (model, reason) =>
            {
                this.isClosed = true;
                Logger.TraceFormat("Channel is closed due to \"{0}\".", reason.ToString());
            };
        }
コード例 #5
0
ファイル: RabbitChannel.cs プロジェクト: mzabolotko/Contour
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="RabbitChannel"/>.
        /// </summary>
        /// <param name="bus">
        /// The bus.
        /// </param>
        /// <param name="native">
        /// The native.
        /// </param>
        public RabbitChannel(RabbitBus bus, IModel native)
        {
            this.bus = bus;
            this.Native = native;

            Logger.TraceFormat("Channel is opened.");

            this.Native.ModelShutdown += (model, reason) =>
                {
                    this.isClosed = true;
                    Logger.TraceFormat("Channel is closed due to \"{0}\".", reason.ToString());
                };
        }
コード例 #6
0
ファイル: Producer.cs プロジェクト: mzabolotko/Contour
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="Producer"/>.
        /// </summary>
        /// <param name="bus">
        /// Конечная точка, для которой создается отправитель.
        /// </param>
        /// <param name="label">
        /// Метка сообщения, которая будет использоваться при отправлении сообщений.
        /// </param>
        /// <param name="routeResolver">
        /// Определитель маршрутов, по которым можно отсылать и получать сообщения.
        /// </param>
        /// <param name="confirmationIsRequired">
        /// Если <c>true</c> - тогда отправитель будет ожидать подтверждения о том, что сообщение было сохранено в брокере.
        /// </param>
        public Producer(RabbitBus bus, MessageLabel label, IRouteResolver routeResolver, bool confirmationIsRequired)
        {
            this.Channel = bus.OpenChannel();
            this.Label = label;
            this.RouteResolver = routeResolver;
            this.ConfirmationIsRequired = confirmationIsRequired;

            if (this.ConfirmationIsRequired)
            {
                this.confirmationTracker = new DefaultPublishConfirmationTracker(this.Channel);
                this.Channel.EnablePublishConfirmation();
                this.Channel.OnConfirmation(this.confirmationTracker.HandleConfirmation);
            }

            this.Failed += _ => ((IBusAdvanced)bus).Panic();
        }
コード例 #7
0
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="Producer"/>.
        /// </summary>
        /// <param name="bus">
        /// Конечная точка, для которой создается отправитель.
        /// </param>
        /// <param name="label">
        /// Метка сообщения, которая будет использоваться при отправлении сообщений.
        /// </param>
        /// <param name="routeResolver">
        /// Определитель маршрутов, по которым можно отсылать и получать сообщения.
        /// </param>
        /// <param name="confirmationIsRequired">
        /// Если <c>true</c> - тогда отправитель будет ожидать подтверждения о том, что сообщение было сохранено в брокере.
        /// </param>
        public Producer(RabbitBus bus, MessageLabel label, IRouteResolver routeResolver, bool confirmationIsRequired)
        {
            this.Channel                = bus.OpenChannel();
            this.Label                  = label;
            this.RouteResolver          = routeResolver;
            this.ConfirmationIsRequired = confirmationIsRequired;

            if (this.ConfirmationIsRequired)
            {
                this.confirmationTracker = new DefaultPublishConfirmationTracker(this.Channel);
                this.Channel.EnablePublishConfirmation();
                this.Channel.OnConfirmation(this.confirmationTracker.HandleConfirmation);
            }

            this.Failed += _ => ((IBusAdvanced)bus).Panic();
        }
コード例 #8
0
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="ListenerRegistry"/>.
 /// </summary>
 /// <param name="bus">
 /// The bus.
 /// </param>
 public ListenerRegistry(RabbitBus bus)
 {
     this.bus = bus;
 }
コード例 #9
0
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="ProducerRegistry"/>.
 /// </summary>
 /// <param name="bus">
 /// The bus.
 /// </param>
 public ProducerRegistry(RabbitBus bus)
 {
     this._bus = bus;
 }
コード例 #10
0
 public RabbitCallbackReceiver(RabbitBus bus, IReceiverConfiguration configuration, IConnectionPool <IRabbitConnection> connectionPool)
     : base(bus, configuration, connectionPool)
 {
 }
コード例 #11
0
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="ProducerRegistry"/>.
 /// </summary>
 /// <param name="bus">
 /// The bus.
 /// </param>
 public ProducerRegistry(RabbitBus bus)
 {
     this._bus = bus;
 }
コード例 #12
0
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="ListenerRegistry"/>.
 /// </summary>
 /// <param name="bus">
 /// The bus.
 /// </param>
 public ListenerRegistry(RabbitBus bus)
 {
     this.bus = bus;
 }