public EventBusRabbitMQModule UseRabbitMQTransport(ContainerBuilderWrapper builder)
 {
     builder.RegisterType(typeof(Implementation.EventBusRabbitMQ)).As(typeof(IEventBus)).SingleInstance();
     builder.RegisterType(typeof(DefaultConsumeConfigurator)).As(typeof(IConsumeConfigurator)).SingleInstance();
     builder.RegisterType(typeof(InMemoryEventBusSubscriptionsManager)).As(typeof(IEventBusSubscriptionsManager)).SingleInstance();
     builder.Register(provider =>
     {
         var logger            = provider.Resolve <ILogger <DefaultRabbitMQPersistentConnection> >();
         EventBusOption option = new EventBusOption();
         var section           = CPlatform.AppConfig.GetSection("EventBus");
         if (section.Exists())
         {
             option = section.Get <EventBusOption>();
         }
         else if (AppConfig.Configuration != null)
         {
             option = AppConfig.Configuration.Get <EventBusOption>();
         }
         var factory = new ConnectionFactory()
         {
             HostName    = option.EventBusConnection,
             UserName    = option.EventBusUserName,
             Password    = option.EventBusPassword,
             VirtualHost = option.VirtualHost,
             Port        = int.Parse(option.Port),
         };
         factory.RequestedHeartbeat = 60;
         AppConfig.BrokerName       = option.BrokerName;
         AppConfig.MessageTTL       = option.MessageTTL;
         AppConfig.RetryCount       = option.RetryCount;
         AppConfig.FailCount        = option.FailCount;
         return(new DefaultRabbitMQPersistentConnection(factory, logger));
     }).As <IRabbitMQPersistentConnection>();
     return(this);
 }
Beispiel #2
0
        public FactoryRabbitMQ(EventBusOption eventBusOption)
        {
            IConnectionFactory conFactory = new ConnectionFactory
            {
                HostName = eventBusOption.Host,
                Port     = eventBusOption.Port,
                UserName = eventBusOption.Username,
                Password = eventBusOption.Password
            };

            connectionFactory = conFactory;
        }
Beispiel #3
0
 public static EventBusOption UseRabbitMQ(this EventBusOption option)
 {
     option.RegisterExtension(new RabbitMQOptionExtension());
     return(option);
 }
Beispiel #4
0
 public static void UseMemory(this EventBusOption option)
 {
     option.RegisterExtension(new EventBusMemoryOption());
 }