public static IRedisConfiguration UseRedis(this IRemoteEventBusConfiguration configuration)
        {
            var iocManager = configuration.AbpStartupConfiguration.IocManager;

            iocManager.IocContainer.Register(
                Component.For <IRemoteEventPublisher>()
                .ImplementedBy <RedisRemoteEventPublisher>()
                .LifestyleSingleton()
                .IsDefault()
                );
            iocManager.IocContainer.Register(
                Component.For <IRemoteEventSubscriber>()
                .ImplementedBy <RedisRemoteEventSubscriber>()
                .LifestyleSingleton()
                .IsDefault()
                );
            iocManager.IocContainer.Register(
                Component.For <IRemoteEventBus>()
                .ImplementedBy <RemoteEventBus>()
                .Named(Guid.NewGuid().ToString())
                .LifestyleSingleton()
                .IsDefault()
                );

            iocManager.RegisterIfNot <IRedisConfiguration, RedisConfiguration>();

            return(iocManager.Resolve <IRedisConfiguration>());
        }
Exemplo n.º 2
0
        public static IRemoteEventBusConfiguration UseRabbitMQ(this IRemoteEventBusConfiguration configuration, RabbitMQSetting setting)
        {
            var settingParam = new TypedParameter(typeof(RabbitMQSetting), setting);

            configuration.IocManger.Resolve <IRemoteEventPublisher>(settingParam);
            configuration.IocManger.Resolve <IRemoteEventSubscriber>(settingParam);
            return(configuration);
        }
Exemplo n.º 3
0
        public static IRemoteEventBusConfiguration UseRabbitMQ(this IRemoteEventBusConfiguration configuration, Action <RabbitMQSetting> configureAction)
        {
            var setting = new RabbitMQSetting();

            configureAction(setting);
            configuration.UseRabbitMQ(setting);
            return(configuration);
        }
Exemplo n.º 4
0
        public static IRemoteEventBusConfiguration AutoSubscribe(this IRemoteEventBusConfiguration configuration)
        {
            var topics = new List <string>();

            configuration.TypeFinder.Find(type => Attribute.IsDefined(type, typeof(RemoteEventHandlerAttribute), false) && typeof(IRemoteEventHandler).IsAssignableFrom(type))
            .ToList().ForEach(type =>
            {
                var attribute = Attribute.GetCustomAttribute(type, typeof(RemoteEventHandlerAttribute)) as RemoteEventHandlerAttribute;
                if (!string.IsNullOrWhiteSpace(attribute.ForTopic) && !topics.Contains(attribute.ForTopic))
                {
                    topics.Add(attribute.ForTopic);
                }
            });
            var _remoteEventBus = configuration.IocManger.Resolve <IRemoteEventBus>();

            _remoteEventBus.Subscribe(topics);
            return(configuration);
        }