private string GetVirtualHostInRawRabbitConfiguration(object busClient)
        {
            RawRabbit.Pipe.PipeContextFactory pipeContextFactory = typeof(RawRabbit.BusClient).GetField("_contextFactory", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(busClient) as PipeContextFactory;

            RawRabbit.Configuration.RawRabbitConfiguration RawRabbitConfiguration = typeof(RawRabbit.Pipe.PipeContextFactory).GetField("_config", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pipeContextFactory) as RawRabbit.Configuration.RawRabbitConfiguration;

            return(RawRabbitConfiguration.VirtualHost);
        }
Ejemplo n.º 2
0
        private void InitClient()
        {
            var busConfig = new RawRabbit.Configuration.RawRabbitConfiguration
            {
                Username    = "******",
                Password    = "******",
                Port        = 5672,
                VirtualHost = "/",
                Hostnames   = { "localhost" }
            };

            _client = BusClientFactory.CreateDefault(busConfig);
        }
Ejemplo n.º 3
0
        public static void AddRabbitMq(this IServiceCollection service, IConfiguration configuration)
        {
            var options = new RawRabbit.Configuration.RawRabbitConfiguration();
            var section = configuration.GetSection("rabbitmq");

            section.Bind(options);

            var client = RawRabbitFactory.CreateSingleton(new RawRabbitOptions
            {
                ClientConfiguration = options
            });

            service.AddSingleton <IBusClient>(_ => client);
        }