Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RabbitMqConsumerChannel" /> class
        /// </summary>
        /// <param name="channelFactory">A <see cref="IChannelFactory" /> used to construct the <see cref="IModel" /> representing Rabbit MQ channel</param>
        /// <param name="mtsChannelSettings">The mts channel settings</param>
        /// <param name="channelSettings">The channel settings</param>
        /// <param name="connectionStatus">The connection status</param>
        public RabbitMqPublisherChannel(IChannelFactory channelFactory, IMtsChannelSettings mtsChannelSettings, IRabbitMqChannelSettings channelSettings, IConnectionStatus connectionStatus)
        {
            Guard.Argument(channelFactory, nameof(channelFactory)).NotNull();
            Guard.Argument(mtsChannelSettings, nameof(mtsChannelSettings)).NotNull();
            Guard.Argument(channelSettings, nameof(channelSettings)).NotNull();
            Guard.Argument(connectionStatus, nameof(connectionStatus)).NotNull();

            _channelFactory = channelFactory;

            _mtsChannelSettings = mtsChannelSettings;

            _channelSettings = channelSettings;

            _useQueue = false;
            if (channelSettings.MaxPublishQueueTimeoutInMs > 0 || channelSettings.PublishQueueLimit > 0)
            {
                _useQueue            = true;
                _msgQueue            = new ConcurrentQueue <PublishQueueItem>();
                _queueLimit          = channelSettings.PublishQueueLimit > 1 ? _channelSettings.PublishQueueLimit : -1;
                _queueTimeout        = channelSettings.MaxPublishQueueTimeoutInMs >= 10000 ? _channelSettings.MaxPublishQueueTimeoutInMs : 15000;
                _queueTimer          = new SdkTimer(new TimeSpan(0, 0, 5), new TimeSpan(0, 0, 1));
                _queueTimer.Elapsed += OnTimerElapsed;
                _queueTimer.FireOnce(new TimeSpan(0, 0, 5));
            }
            _shouldBeOpened = 0;

            UniqueId = _channelFactory.GetUniqueId();

            _connectionStatus = (ConnectionStatus)connectionStatus;
        }
Example #2
0
        internal TicketCashoutSender(ITicketMapper <ITicketCashout, TicketCashoutDTO> ticketMapper,
                                     IRabbitMqPublisherChannel publisherChannel,
                                     ConcurrentDictionary <string, TicketCacheItem> ticketCache,
                                     IMtsChannelSettings mtsChannelSettings,
                                     IRabbitMqChannelSettings rabbitMqChannelSettings)
            : base(publisherChannel, ticketCache, mtsChannelSettings, rabbitMqChannelSettings)
        {
            Guard.Argument(ticketMapper, nameof(ticketMapper)).NotNull();

            _ticketMapper = ticketMapper;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RabbitMqConsumerChannel"/> class
        /// </summary>
        /// <param name="channelFactory">A <see cref="IChannelFactory"/> used to construct the <see cref="IModel"/> representing Rabbit MQ channel</param>
        /// <param name="mtsChannelSettings"></param>
        /// <param name="channelSettings"></param>
        public RabbitMqConsumerChannel(IChannelFactory channelFactory,
                                       IMtsChannelSettings mtsChannelSettings,
                                       IRabbitMqChannelSettings channelSettings)
        {
            Guard.Argument(channelFactory, nameof(channelFactory)).NotNull();
            Guard.Argument(mtsChannelSettings, nameof(mtsChannelSettings)).NotNull();

            _channelFactory     = channelFactory;
            _mtsChannelSettings = mtsChannelSettings;
            _channelSettings    = channelSettings;

            _queueName = _mtsChannelSettings.ChannelQueueName;

            _shouldBeOpened = 0;

            UniqueId              = _channelFactory.GetUniqueId();
            _healthTimer          = new SdkTimer(new TimeSpan(0, 0, _timerInterval), new TimeSpan(0, 0, 1));
            _healthTimer.Elapsed += OnTimerElapsed;
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TicketSenderBase"/> class
        /// </summary>
        /// <param name="publisherChannel">The publisher channel</param>
        /// <param name="ticketCache">The ticket cache</param>
        /// <param name="mtsChannelSettings">The MTS channel settings</param>
        /// <param name="rabbitMqChannelSettings">Rabbit channel settings</param>
        internal TicketSenderBase(IRabbitMqPublisherChannel publisherChannel,
                                  ConcurrentDictionary <string, TicketCacheItem> ticketCache,
                                  IMtsChannelSettings mtsChannelSettings,
                                  IRabbitMqChannelSettings rabbitMqChannelSettings)
        {
            Guard.Argument(publisherChannel, nameof(publisherChannel)).NotNull();
            Guard.Argument(ticketCache, nameof(ticketCache)).NotNull();
            Guard.Argument(mtsChannelSettings, nameof(mtsChannelSettings)).NotNull();
            Guard.Argument(rabbitMqChannelSettings, nameof(rabbitMqChannelSettings)).NotNull();

            _publisherChannel        = publisherChannel;
            _ticketCache             = ticketCache;
            _mtsChannelSettings      = mtsChannelSettings;
            _rabbitMqChannelSettings = rabbitMqChannelSettings;
            _publisherChannel.MqMessagePublishFailed += PublisherChannelOnMqMessagePublishFailed;

            _timer          = new SdkTimer(new TimeSpan(0, 0, 0, 0, GetCacheTimeout(null)), new TimeSpan(0, 0, 10));
            _timer.Elapsed += OnTimerElapsed;
            _timer.FireOnce(new TimeSpan(0, 0, 0, 0, GetCacheTimeout(null)));
        }