public ColaboradorEventHandler(
     IRabbitMQBus rabbitMQBus,
     ICodeiziConfiguration configuration)
 {
     _rabbitMQBus   = rabbitMQBus;
     _configuration = configuration;
 }
 /// <summary>
 /// 使用Autofac的方式进行对象反射
 /// </summary>
 /// <param name="service"></param>
 /// <param name="services"></param>
 /// <param name="butterflySetup"></param>
 public static void AddAutofac(this RabbitMQConfig service, IServiceCollection services, Action <ButterflyOptions> butterflySetup = null)
 {
     if (butterflySetup != null)
     {
         try
         {
             services.AddButterfly(butterflySetup);
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
     services.AddSingleton(options =>
     {
         ILifetimeScope lifetime = options.GetRequiredService <ILifetimeScope>();
         IRabbitMQBus bus        = options.GetRequiredService <IRabbitMQBus>();
         ILogger <AutofacMessageReceive> logger = options.GetService <ILogger <AutofacMessageReceive> >();
         IServiceTracer tracer = null;
         if (butterflySetup != null)
         {
             try
             {
                 tracer = options.GetRequiredService <IServiceTracer>();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
             }
         }
         return(new AutofacMessageReceive(lifetime, bus, tracer, logger));
     });
 }
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lifetime"></param>
 /// <param name="service"></param>
 /// <param name="tracer"></param>
 /// <param name="logger"></param>
 public AutofacMessageReceive(ILifetimeScope lifetime, IRabbitMQBus service, IServiceTracer tracer, ILogger <AutofacMessageReceive> logger)
 {
     _lifetime = lifetime;
     _service  = service;
     _tracer   = tracer;
     _logger   = logger;
     _service.OnMessageReceived += RabbitMQ_OnMessageReceived;
     _service.OnPublish         += RabbitMQ_OnPublish;
 }
Beispiel #4
0
 public ContratoParaCalculoBackgroundService(IOptions <BackgroundTaskConfigurations> settings,
                                             ILogger <ContratoParaCalculoBackgroundService> logger,
                                             IConfiguration configuration,
                                             IRabbitMQBus rabbitMQBus)
 {
     _settings     = settings?.Value ?? throw new ArgumentNullException(nameof(settings));
     _logger       = logger ?? throw new ArgumentNullException(nameof(logger));
     _rabbitMQBus  = rabbitMQBus;
     Configuration = configuration;
 }
        /// <summary>
        /// 激活RabbitMQBus的Autofac
        /// </summary>
        /// <param name="app"></param>
        /// <param name="autoSubscribe"></param>
        public static void UseRabbitMQBus(this IApplicationBuilder app, bool autoSubscribe = false)
        {
            if (autoSubscribe)
            {
                IRabbitMQBus bus = app.ApplicationServices.GetRequiredService <IRabbitMQBus>();
                bus.AutoSubscribe();
            }
            AutofacMessageReceive service = app.ApplicationServices.GetRequiredService <AutofacMessageReceive>();

            service.Active();
        }
Beispiel #6
0
 public FeriasEventHandler(IRabbitMQBus rabbitMQBus)
 => _rabbitMQBus = rabbitMQBus;