Ejemplo n.º 1
0
 public RabbitResponseQueuePrepared(ILogger <RabbitResponseQueuePrepared> log, RabbitClientOptions option,
                                    IRabbitConnectionFactory connectionFactory)
 {
     _log               = log;
     _option            = option;
     _connectionFactory = connectionFactory;
 }
Ejemplo n.º 2
0
 public RabbitEnvelopeSender(
     ITopologyService topologyService,
     IRabbitConnectionFactory connFactory)
 {
     _topologyService = topologyService;
     _connFactory     = connFactory;
 }
 public RabbitEnvelopeSender(
     ITopologyService topologyService,
     IRabbitConnectionFactory connFactory)
 {
     _topologyService = topologyService;
     _connFactory = connFactory;
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RabbitBroker" /> class.
 /// </summary>
 /// <param name="connectionFactory">
 ///     The <see cref="IRabbitConnectionFactory" /> to be used to create the channels to connect to the
 ///     endpoints.
 /// </param>
 /// <param name="serviceProvider">
 ///     The <see cref="IServiceProvider" /> to be used to resolve the required services.
 /// </param>
 public RabbitBroker(
     IRabbitConnectionFactory connectionFactory,
     IServiceProvider serviceProvider)
     : base(serviceProvider)
 {
     _connectionFactory = connectionFactory;
 }
        public SendMessagesService(IRabbitConnectionFactory rabbitConnectionFactory, ISettings settings)
        {
            Verify.RequireNotNull(rabbitConnectionFactory, "rabbitConnectionFactory");
            Verify.RequireNotNull(settings, "settings");

            this.rabbitConnectionFactory = rabbitConnectionFactory;
            this.settings = settings;
        }
Ejemplo n.º 6
0
        /// <inheritdoc />
        public RabbitQueueClient(RabbitClientOptions option, IRabbitResponseQueuePrepared queuePrepared, ILogger <RabbitQueueClient> log, IRabbitConnectionFactory connectionFactory, IOptions <RabbitRequestOption> opt)
        {
            _option = option ?? throw new ArgumentNullException(nameof(option));

            _queuePrepared     = queuePrepared;
            _log               = log;
            _connectionFactory = connectionFactory;
        }
Ejemplo n.º 7
0
 public RabbitHandler(IRabbitConnectionFactory connectionFactory)
 {
     listeners   = new Dictionary <string, Func <object, Task> >();
     _connection = connectionFactory.CreateConnection();
     InitializeListeningChannel();
     InitializeDeadLetterQueue();
     InitializeSubscribers();
     RegisterConsumer();
 }
Ejemplo n.º 8
0
        public RabbitEnvelopeReceiver(
            ITopologyService topologyService,
            IRabbitConnectionFactory connFactory)
        {
            _topologyService = topologyService;
            _connFactory     = connFactory;

            _listeners = new Dictionary <IRegistration, RabbitListener>();
        }
        public RabbitEnvelopeReceiver(
            ITopologyService topologyService,
            IRabbitConnectionFactory connFactory)
        {
            _topologyService = topologyService;
            _connFactory = connFactory;

            _listeners = new Dictionary<IRegistration, RabbitListener>();
        }
Ejemplo n.º 10
0
        public RabbitTransportProvider(
            ITopologyService topologyService,
            IRabbitConnectionFactory connFactory)
        {
            _topoSvc = topologyService;
            _connFactory = connFactory;

            _listeners = new Dictionary<IRegistration, RabbitListener>();

            _log = LogManager.GetLogger(this.GetType());
        }
Ejemplo n.º 11
0
        public RabbitTransportProvider(
            ITopologyService topologyService,
            IRabbitConnectionFactory connFactory,
            IRoutingInfoCache routingInfoCache)
        {
            _topoSvc          = topologyService;
            _connFactory      = connFactory;
            _routingInfoCache = routingInfoCache;

            _listeners = new Dictionary <IRegistration, RabbitListener>();
        }
        public RabbitTransportProvider(
            ITopologyService topologyService,
            IRabbitConnectionFactory connFactory,
            IRoutingInfoCache routingInfoCache)
        {
            _topoSvc = topologyService;
            _connFactory = connFactory;
            _routingInfoCache = routingInfoCache;

            _listeners = new Dictionary<IRegistration, RabbitListener>();
        }
Ejemplo n.º 13
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RabbitConsumer" /> class.
 /// </summary>
 /// <param name="broker">
 ///     The <see cref="IBroker" /> that is instantiating the consumer.
 /// </param>
 /// <param name="endpoint">
 ///     The endpoint to be consumed.
 /// </param>
 /// <param name="behaviorsProvider">
 ///     The <see cref="IBrokerBehaviorsProvider{TBehavior}"/>.
 /// </param>
 /// <param name="connectionFactory">
 ///     The <see cref="IRabbitConnectionFactory" /> to be used to create the channels to connect to the
 ///     endpoint.
 /// </param>
 /// <param name="serviceProvider">
 ///     The <see cref="IServiceProvider" /> to be used to resolve the needed services.
 /// </param>
 /// <param name="logger">
 ///     The <see cref="ISilverbackIntegrationLogger" />.
 /// </param>
 public RabbitConsumer(
     RabbitBroker broker,
     RabbitConsumerEndpoint endpoint,
     IBrokerBehaviorsProvider <IConsumerBehavior> behaviorsProvider,
     IRabbitConnectionFactory connectionFactory,
     IServiceProvider serviceProvider,
     ISilverbackIntegrationLogger <RabbitConsumer> logger)
     : base(broker, endpoint, behaviorsProvider, serviceProvider, logger)
 {
     _connectionFactory = connectionFactory;
     _logger            = logger;
 }
        /// <summary>
        /// Adds the RabbitMQ sink to serilog
        /// </summary>
        /// <param name="configuration">Serilog Sink Configuration.</param>
        /// <param name="rabbitConnectionFactory">The <see cref="IRabbitConnectionFactory" /> to use when creating the connection to RabbitMQ.</param>
        /// <param name="rabbitMessageBuilder">The <see cref="IRabbitMessageBuilder" /> to use when sending messages to RabbitMQ.</param>
        /// <param name="batchSizeLimit">Maximum locally queued message count before sending to RabbitMQ.</param>
        /// <param name="batchSubmitTimeSeconds">Maximum time to allow locally queued messages to be queued before sending to RabbitMQ.</param>
        /// <param name="textFormatter">The ITextFormatter to use when formatting the message. If null, this will default to the built-in Serilog JsonFormatter.</param>
        /// <param name="formatProvider">The IFormatProvider to use when formatting the message. If null, this will default to the standard .NET format provider.</param>
        /// <returns></returns>
        public static LoggerConfiguration RabbitMQ(this LoggerSinkConfiguration configuration,
                                                   IRabbitConnectionFactory rabbitConnectionFactory,
                                                   IRabbitMessageBuilder rabbitMessageBuilder,
                                                   int batchSizeLimit             = 50,
                                                   int batchSubmitTimeSeconds     = 2,
                                                   ITextFormatter textFormatter   = null,
                                                   IFormatProvider formatProvider = null)
        {
            var sink = new RabbitMQSink(batchSizeLimit,
                                        TimeSpan.FromSeconds(batchSubmitTimeSeconds),
                                        textFormatter,
                                        formatProvider,
                                        rabbitConnectionFactory,
                                        rabbitMessageBuilder);

            return(configuration.Sink(sink));
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="RabbitProducer" /> class.
        /// </summary>
        /// <param name="broker">
        ///     The <see cref="IBroker" /> that instantiated this producer.
        /// </param>
        /// <param name="endpoint">
        ///     The endpoint to produce to.
        /// </param>
        /// <param name="behaviorsProvider">
        ///     The <see cref="IBrokerBehaviorsProvider{TBehavior}" />.
        /// </param>
        /// <param name="serviceProvider">
        ///     The <see cref="IServiceProvider" /> to be used to resolve the needed services.
        /// </param>
        /// <param name="connectionFactory">
        ///     The <see cref="IRabbitConnectionFactory" /> to be used to create the channels to connect to the
        ///     endpoint.
        /// </param>
        /// <param name="logger">
        ///     The <see cref="ISilverbackLogger" />.
        /// </param>
        public RabbitProducer(
            RabbitBroker broker,
            RabbitProducerEndpoint endpoint,
            IBrokerBehaviorsProvider <IProducerBehavior> behaviorsProvider,
            IRabbitConnectionFactory connectionFactory,
            IServiceProvider serviceProvider,
            ISilverbackIntegrationLogger <Producer> logger)
            : base(broker, endpoint, behaviorsProvider, serviceProvider, logger)
        {
            _connectionFactory = connectionFactory;
            _logger            = logger;

            Task.Factory.StartNew(
                () => ProcessQueue(_cancellationTokenSource.Token),
                CancellationToken.None,
                TaskCreationOptions.LongRunning,
                TaskScheduler.Default);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// The Serilog sink that will send log messages to a RabbitMQ server
        /// </summary>
        /// <param name="batchSizeLimit">Maximum locally queued message count before sending to RabbitMQ.</param>
        /// <param name="batchSubmitTimeSeconds">Maximum time to allow locally queued messages to be queued before sending to RabbitMQ.</param>
        /// <param name="textFormatter">The ITextFormatter to use when formatting the message. If null, this will default to the built-in Serilog JsonFormatter.</param>
        /// <param name="formatProvider">The IFormatProvider to use when formatting the message. If null, this will default to the standard .NET format provider.</param>
        /// <param name="rabbitConnectionFactory">The <see cref="IRabbitConnectionFactory" /> to use when creating the connection to RabbitMQ.</param>
        /// <param name="rabbitMessageBuilder">The <see cref="IRabbitMessageBuilder" /> to use when sending messages to RabbitMQ.</param>
        public RabbitMQSink(int batchSizeLimit,
                            TimeSpan batchSubmitTimeSeconds,
                            ITextFormatter textFormatter,
                            IFormatProvider formatProvider,
                            IRabbitConnectionFactory rabbitConnectionFactory,
                            IRabbitMessageBuilder rabbitMessageBuilder)
            : base(batchSizeLimit, batchSubmitTimeSeconds)
        {
            _formatProvider = formatProvider;
            _textFormatter  = textFormatter ?? new JsonFormatter(renderMessage: true);

            _connectionFactory    = rabbitConnectionFactory.GetConnectionFactory();
            _rabbitMessageBuilder = rabbitMessageBuilder;

            _connection      = _connectionFactory.CreateConnection();
            _model           = _connection.CreateModel();
            _basicProperties = _model.CreateBasicProperties();

            rabbitConnectionFactory.ConfigureBasicProperties(_basicProperties);
        }
Ejemplo n.º 17
0
        public QueuePoller(IQueueSettings queueSettings, CancellationToken cancellationToken, IRabbitConnectionFactory rabbitConnectionFactory,
                           IHeaderParser headerParser, IDocumentStore documentStore, IActiveQueuePollers activeQueuePollers, IStoreMessagesFactory storeMessagesFactory)
        {
            Verify.RequireNotNull(queueSettings, "queueSettings");
            Verify.RequireNotNull(cancellationToken, "cancellationToken");
            Verify.RequireNotNull(headerParser, "headerParser");
            Verify.RequireNotNull(documentStore, "documentStore");
            Verify.RequireNotNull(rabbitConnectionFactory, "rabbitConnectionFactory");
            Verify.RequireNotNull(activeQueuePollers, "activeQueuePollers");
            Verify.RequireNotNull(storeMessagesFactory, "storeMessagesFactory");

            QueueSettings                = queueSettings;
            this.cancellationToken       = cancellationToken;
            this.rabbitConnectionFactory = rabbitConnectionFactory;
            this.headerParser            = headerParser;
            this.documentStore           = documentStore;
            this.activeQueuePollers      = activeQueuePollers;
            this.storeMessagesFactory    = storeMessagesFactory;
            Key = Guid.NewGuid();

            messageMeter = Metric.Meter(string.Format("RabbitOperations.QueuePoller.Messages.{0}.{1}", QueueSettings.ApplicationId, QueueSettings.QueueName), Unit.Items, TimeUnit.Seconds, tags: new MetricTags("QueuePoller"));
        }
Ejemplo n.º 18
0
 public LogController(IDeviceRepository deviceRepository,IRabbitConnectionFactory rabbitConnectionFactory)
 {
     _deviceRepository = deviceRepository;
     _rabbitConnectionFactory = rabbitConnectionFactory;
 }
Ejemplo n.º 19
0
 public RabbitPublisher(IRabbitConnectionFactory connectionFactory)
 {
     _connectionFactory = connectionFactory;
 }
 public RabbitService(IOptions <RabbitSettings> rabbitSettings, IRabbitConnectionFactory rabbitConnectionFactory)
 {
     _conn    = rabbitConnectionFactory.CreateConnection(rabbitSettings.Value);
     _channel = _conn.CreateModel();
     _channel.ExchangeDeclare(exchange: "users", type: ExchangeType.Fanout);
 }
Ejemplo n.º 21
0
 public RabbitLogBus(IRabbitConnectionFactory rabbitConnectionFactory)
 {
     _rabbitConnectionFactory = rabbitConnectionFactory;
     _list=new List<ConnectedQueue>();
 }
Ejemplo n.º 22
0
 public TestHandler(IRabbitConnectionFactory connectionFactory)
     : base(connectionFactory)
 {
     BeforeExecution += QueueHandler_BeforeExecution;
     AfterExecution  += QueueHandler_AfterExecution;
 }
Ejemplo n.º 23
0
 public RabbitConnectionManager(IRabbitConnectionFactory connectionFactory, IRabbitChannelFactory rabbitChannelFactory, RabbitOptions options)
 {
     _connectionFactory    = connectionFactory;
     _rabbitChannelFactory = rabbitChannelFactory;
     _options = options;
 }