Beispiel #1
0
        public static ClientProxy <TService> CreateClientProxy <TService>(MQOptions options, int timeoutInterval = 1200000, int hearbeatInterval = 10000)
            where TService : class
        {
            var opt = new RabbitMQClientConnectionFactoryOptions(options, NullLoggerFactory.Instance);

            return(CreateClientProxy <TService>(opt, timeoutInterval, hearbeatInterval));
        }
Beispiel #2
0
        public static IHost CreateHost(MQOptions mqOptions, MiddlewareOptions middlewareOptions, params Contract[] contracts)
        {
            return(new HostBuilder()
                   .ConfigureServices((context, services) =>
            {
                services.AddNetRpcRabbitMQService(i =>
                {
                    if (mqOptions != null)
                    {
                        i.CopyFrom(mqOptions);
                    }
                });
                services.AddNetRpcMiddleware(i =>
                {
                    if (middlewareOptions != null)
                    {
                        i.AddItems(middlewareOptions.GetItems());
                    }
                });

                foreach (var contract in contracts)
                {
                    services.AddNetRpcServiceContract(contract.ContractInfo.Type, contract.InstanceType);
                }
            })
                   .Build());
        }
        private void Reset(MQOptions opt)
        {
            if (_service != null)
            {
                _service.Dispose();
                _service.ReceivedAsync -= ServiceReceivedAsync;
            }

            _service = new Service(opt.CreateConnectionFactory(), opt.RpcQueue, opt.PrefetchCount, _logger);
            _service.ReceivedAsync += ServiceReceivedAsync;
        }
        private void Reset(MQOptions opt, IServiceProvider serviceProvider)
        {
            if (_service != null)
            {
                _service.Dispose();
                _service.Received -= ServiceReceived;
            }

            _service           = new Service(opt.CreateConnectionFactory(), opt.RpcQueue, opt.PrefetchCount, _logger);
            _requestHandler    = new RequestHandler(serviceProvider, ChannelType.RabbitMQ);
            _service.Received += ServiceReceived;
        }
Beispiel #5
0
 public static ConnectionFactory CreateConnectionFactory(this MQOptions options)
 {
     return(new ConnectionFactory
     {
         UserName = options.User,
         Password = options.Password,
         VirtualHost = options.VirtualHost,
         HostName = options.Host,
         Port = options.Port,
         AutomaticRecoveryEnabled = true,
         NetworkRecoveryInterval = TimeSpan.FromSeconds(5)
     });
 }
Beispiel #6
0
 public RabbitMQClientConnection(IConnection connect, MQOptions opt, ILogger logger)
 {
     _opt            = opt;
     _call           = new RabbitMQOnceCall(connect, opt.RpcQueue, logger);
     _call.Received += CallReceived;
 }
 public RabbitMQClientConnectionFactoryOptions(MQOptions options, ILoggerFactory loggerFactory)
 {
     Factory = new RabbitMQClientConnectionFactory(
         new SimpleOptions <RabbitMQClientOptions>(new RabbitMQClientOptions(options)), loggerFactory);
 }
 public RabbitMQClientConnectionFactory(IOptions <RabbitMQClientOptions> options, ILoggerFactory factory)
 {
     _logger     = factory.CreateLogger("NetRpc");
     _options    = options.Value;
     _connection = _options.CreateConnectionFactory().CreateConnection();
 }