public AsyncBasicRpcServer(IOptions <RpcServerConfiguration> rpcServerConfiguration, IRabbitConnectionManager rabbitConnectionManager, ILogger logger)
        {
            var options = rpcServerConfiguration.Value;

            _requestQueue            = options.RequestQueue;
            _threadCount             = options.ThreadCount ?? 1;
            _rabbitConnectionManager = rabbitConnectionManager;
            _channelsInUse           = new ConcurrentDictionary <string, IModel>();
            _logger = logger;
        }
Ejemplo n.º 2
0
 public AsyncRpcClient(IOptions <RpcClientConfiguration> rpcClientConfiguration, IRabbitConnectionManager rabbitConnectionManager, ILogger <AsyncRpcClient> logger)
 {
     _logger                  = logger;
     _requestQueue            = rpcClientConfiguration.Value.RequestQueue;
     _threadCount             = rpcClientConfiguration.Value.ThreadCount;
     _timeout                 = rpcClientConfiguration.Value.Timeout ?? Timeout.InfiniteTimeSpan;
     _rabbitConnectionManager = rabbitConnectionManager;
     _pendingMessages         = new ConcurrentDictionary <string, TaskCompletionSource <byte[]> >();
     _channel                 = rabbitConnectionManager.GetChannel();
     _consumer                = new AsyncEventingBasicConsumer(_channel);
     _consumer.Received      += async(model, ea) => {
         _pendingMessages.TryRemove(ea.BasicProperties.CorrelationId, out var tcs);
         if (tcs != null)
         {
             tcs.SetResult(ea.Body);
         }
         else
         {
             _logger.LogWarning("No result on {CorrelationId}", ea.BasicProperties.CorrelationId);
         }
     };
     _channel.BasicQos(0, (ushort?)_threadCount ?? 1, false);
     _channel.BasicConsume(_replyQueue.QueueName, true, _consumer);
 }
Ejemplo n.º 3
0
 public AsyncBasicConsumer(IRabbitConnectionManager rabbitConnectionManager, ILogger <AsyncBasicConsumer> logger)
 {
     _channel = rabbitConnectionManager.GetChannel();
     _logger  = logger;
 }
Ejemplo n.º 4
0
 public RabbitConsumerApp(IRabbitConnectionManager manager, T consumer, RabbitConsumerOptions options)
 {
     _manager  = manager;
     _consumer = consumer;
     _options  = options;
 }
Ejemplo n.º 5
0
 public RabbitPublisher(IRabbitConnectionManager connectionManager, PublisherOptions <T> options)
 {
     _connectionManager = connectionManager;
     _options           = options;
 }
 public BaseRabbitPublisher(IRabbitConnectionManager rabbitChannelManager)
 {
     _rabbitChannelManager = rabbitChannelManager;
 }