protected override MessageBus CreateMessageBus()
        {
            var configuration = new RedisScaleoutConfiguration(RunData.RedisServer, RunData.RedisPort, RunData.RedisPassword, "Stress");
            // configuration.RetryOnError = true;

            return new RedisMessageBus(Resolver, configuration);
        }
Пример #2
0
        protected override MessageBus CreateMessageBus()
        {
            var configuration = new RedisScaleoutConfiguration(RunData.RedisServer, RunData.RedisPort, RunData.RedisPassword, "Stress");
            // configuration.MaxQueueLength = 1000;

            return new RedisMessageBus(Resolver, configuration);
        }
        internal RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration, IRedisConnection connection, bool connectAutomatically)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _connection = connection;

            _connectionString = configuration.ConnectionString;
            _db  = configuration.Database;
            _key = configuration.EventKey;

            _traceManager = resolver.Resolve <ITraceManager>();

            _trace = _traceManager["SignalR." + nameof(RedisMessageBus)];

            ReconnectDelay = TimeSpan.FromSeconds(2);

            if (connectAutomatically)
            {
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    var ignore = ConnectWithRetry();
                });
            }
        }
Пример #4
0
        internal RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration, IRedisConnection connection, bool connectAutomatically)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _connection = connection;

            _connectionString = configuration.ConnectionString;
            _db = configuration.Database;
            _key = configuration.EventKey;

            var traceManager = resolver.Resolve<ITraceManager>();

            _trace = traceManager["SignalR." + typeof(RedisMessageBus).Name];

            ReconnectDelay = TimeSpan.FromSeconds(2);

            if (connectAutomatically)
            {
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    var ignore = ConnectWithRetry();
                });
            }
        }
Пример #5
0
        public void Configuration(IAppBuilder app)
        {
            app.UseHealthCheck("/health", new HealthCheckMiddlewareConfig());

            // 有关如何配置应用程序的详细信息,请访问 https://go.microsoft.com/fwlink/?LinkID=316888
            app.UseAesDataProtectorProvider(_startupModel.EncryptionPassword);

#if !DEBUG
            var redisHost = _startupModel.Host.Split(' ')[0];
            var redis     = new RedisScaleoutConfiguration(redisHost, _startupModel.EventAppName);
            GlobalHost.DependencyResolver.UseRedis(redis);
#endif

            GlobalHost.DependencyResolver.Register(typeof(QrCodeHub), () => new QrCodeHub());
            app.Map("/signalr", map =>
            {
                //ref: https://forums.asp.net/t/2033309.aspx?Calling+SignalR+hub+from+other+domain+via+CORS
                map.UseCors(CorsOptions.AllowAll);
                var hubConfiguration = new HubConfiguration()
                {
                    //EnableJSONP = true,
                    EnableDetailedErrors = true,
                    //EnableJavaScriptProxies = true
                };

                map.RunSignalR(hubConfiguration);
            });
        }
Пример #6
0
        protected override MessageBus CreateMessageBus()
        {
            var configuration = new RedisScaleoutConfiguration(RunData.RedisServer, RunData.RedisPort, RunData.RedisPassword, "Stress");

            // configuration.MaxQueueLength = 1000;

            return(new RedisMessageBus(Resolver, configuration));
        }
Пример #7
0
        protected override MessageBus CreateMessageBus()
        {
            var configuration = new RedisScaleoutConfiguration(RunData.RedisServer, RunData.RedisPort, RunData.RedisPassword, "Stress");

            // configuration.RetryOnError = true;

            return(new RedisMessageBus(Resolver, configuration));
        }
Пример #8
0
 public void Configuration(IAppBuilder app)
 {
     //允许CORS跨域
     app.UseCors(CorsOptions.AllowAll);
     #region Redis配置
     //添加redis
     RedisScaleoutConfiguration redisScaleoutConfiguration = new RedisScaleoutConfiguration("192.168.10.134", 6379, "111111", "redis_signalr");
     //连接DB,默认为0
     redisScaleoutConfiguration.Database = 3;
     //SignalR用Redis
     GlobalHost.DependencyResolver.UseRedis(redisScaleoutConfiguration);
     #endregion
     // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888
     app.MapSignalR();//启动SignalR
 }
Пример #9
0
        public RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _connectionFactory = configuration.ConnectionFactory;
            _db = configuration.Database;
            _key = configuration.EventKey;

            ReconnectDelay = TimeSpan.FromSeconds(2);
            ConnectWithRetry();
        }
Пример #10
0
        public RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _connectionFactory = configuration.ConnectionFactory;
            _db  = configuration.Database;
            _key = configuration.EventKey;

            ReconnectDelay = TimeSpan.FromSeconds(2);
            ConnectWithRetry();
        }
Пример #11
0
        private static void ConfigureSignalR(IAppBuilder app)
        {
            app.UseAesDataProtectorProvider(SignalRScaleoutConfiguration.EncryptionPassword);

            if (SignalRScaleoutConfiguration.UseScaleout)
            {
                var redisConfig = new RedisScaleoutConfiguration(
                    SignalRScaleoutConfiguration.RedisConnectionString,
                    SignalRScaleoutConfiguration.RedisAppName);
                GlobalHost.DependencyResolver.UseRedis(redisConfig);
            }

            var configuration = new HubConfiguration {
                EnableDetailedErrors = true
            };

            app.MapSignalR(configuration);
        }
Пример #12
0
        public RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _connectionFactory = configuration.ConnectionFactory;
            _db = configuration.Database;
            _key = configuration.EventKey;

            var traceManager = resolver.Resolve<ITraceManager>();
            _trace = traceManager["SignalR." + typeof(RedisMessageBus).Name];

            ReconnectDelay = TimeSpan.FromSeconds(2);
            ConnectWithRetry();
        }
Пример #13
0
        public RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _connectionFactory = configuration.ConnectionFactory;
            _db  = configuration.Database;
            _key = configuration.EventKey;

            var traceManager = resolver.Resolve <ITraceManager>();

            _trace = traceManager["SignalR." + typeof(RedisMessageBus).Name];

            ReconnectDelay = TimeSpan.FromSeconds(2);
            ConnectWithRetry();
        }
Пример #14
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RedisConnectionInfo redisInfo = Settings.Current.RedisConnectionInfo;

            if (Settings.Current.EnableSignalR && redisInfo != null)
            {
                var config = new RedisScaleoutConfiguration(redisInfo.Host, redisInfo.Port, redisInfo.Password, "exceptionless.signalr");
                GlobalHost.DependencyResolver.UseRedis(config);
            }

            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            AuthConfig.RegisterAuth();

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            AutoMapperConfig.CreateMappings();

            Trace.Listeners.Add(new NLogTraceListener());
            if (ExceptionlessClient.Current.Configuration.Enabled)
            {
                ExceptionlessClient.Current.Log = new NLogExceptionlessLog();
                ExceptionlessClient.Current.RegisterWebApi(GlobalConfiguration.Configuration);
                ExceptionlessClient.Current.UnhandledExceptionReporting += CurrentOnUnhandledExceptionReporting;
            }

            // startup the message queue
            JobManager.Current.JobManagerStarted += (sender, args) => JobManager.Current.RunJob("StartMq");

            // make the notification sender listen for messages
            var notificationSender = DependencyResolver.Current.GetService <NotificationSender>();

            notificationSender.Listen();
        }
Пример #15
0
 internal MockRedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration, IRedisConnection connection, bool connectAutomatically) : base(resolver, configuration, connection, connectAutomatically)
 {
 }
Пример #16
0
        public void DatabaseFromConnectionstringIsUsed()
        {
            var configuration = new RedisScaleoutConfiguration("localhost,defaultDatabase=5", String.Empty);

            Assert.Equal(configuration.Database, 5);
        }
Пример #17
0
 public RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration, IRedisConnection connection)
     : this(resolver, configuration, connection, true)
 {
 }
Пример #18
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        private static void ConfigureAuth(IAppBuilder app)
        {
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(2),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)),
                    OnApplyRedirect = ctx =>
                    {
                        if (!IsApiRequest(ctx.Request))
                        {
                            ctx.Response.Redirect(ctx.RedirectUri);
                        }
                    }
                },
#if !DEBUG
                CookieSecure = CookieSecureOption.Always,
#endif
                CookieName     = "Cryptopia",
                LoginPath      = new PathString("/Login"),
                ExpireTimeSpan = TimeSpan.FromHours(8),
                LogoutPath     = new PathString("/LogOff"),
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            //app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Signalr
            var hubConfiguration = new HubConfiguration
            {
#if DEBUG
                EnableDetailedErrors = true,
#else
                EnableDetailedErrors = false
#endif
            };

            var useRedisSignalr = bool.Parse(WebConfigurationManager.AppSettings["Signalr_ScaleOut_Redis_Enabled"]);
            if (useRedisSignalr)
            {
                var redisConnection = WebConfigurationManager.AppSettings["Signalr_ScaleOut_Redis_Connection"];
                var redisConfig     = new RedisScaleoutConfiguration(redisConnection, "Cryptopia.Signalr");
                redisConfig.MaxQueueLength = int.MaxValue;
                redisConfig.QueueBehavior  = QueuingBehavior.Always;
                GlobalHost.DependencyResolver.UseRedis(redisConfig);
            }

            var useSqlSignalr = bool.Parse(WebConfigurationManager.AppSettings["Signalr_ScaleOut_Sql_Enabled"]);
            if (useSqlSignalr)
            {
                var sqlConnection = WebConfigurationManager.ConnectionStrings["SignalrBackplane"].ConnectionString;
                var sqlConfig     = new SqlScaleoutConfiguration(sqlConnection);
                sqlConfig.TableCount     = int.Parse(WebConfigurationManager.AppSettings["Signalr_ScaleOut_Sql_TableCount"]);
                sqlConfig.MaxQueueLength = int.MaxValue;
                sqlConfig.QueueBehavior  = QueuingBehavior.Always;
                GlobalHost.DependencyResolver.UseSqlServer(sqlConfig);
            }

            GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => new HubIdentityProvider());
            GlobalHost.Configuration.DefaultMessageBufferSize = 200;
            app.MapSignalR(hubConfiguration);
        }
Пример #19
0
 public RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration, IRedisConnection connection)
     : this(resolver, configuration, connection, true)
 {
 }