Esempio n. 1
0
        public async Task CountTheConnections()
        {
            var activeConnections = new ConcurrentDictionary <int, object>();

            var bus = Configure.With(new BuiltinHandlerActivator())
                      .Transport(t => t.Register(c =>
            {
                var connectionProvider = new TestConnectionProvider(SqlTestHelper.ConnectionString, activeConnections);
                var transport          = new SqlServerTransport(connectionProvider, "RebusMessages", "bimse", c.Get <IRebusLoggerFactory>(), c.Get <IAsyncTaskFactory>());

                transport.EnsureTableIsCreated();

                return(transport);
            }))
                      .Start();

            using (var printTimer = new Timer(1000))
            {
                printTimer.Elapsed += delegate
                {
                    Console.WriteLine("Active connections: {0}", activeConnections.Count);
                };
                printTimer.Start();

                using (bus)
                {
                    await Task.Delay(TimeSpan.FromSeconds(5));
                }
            }
        }
Esempio n. 2
0
        protected override void SetUp()
        {
            SqlTestHelper.DropTable(_tableName);

            _transport = new SqlServerTransport(new DbConnectionProvider(SqlTestHelper.ConnectionString), _tableName, QueueName);
            _transport.EnsureTableIsCreated();

            Using(_transport);

            _transport.Initialize();
        }
Esempio n. 3
0
        protected override void SetUp()
        {
            SqlTestHelper.DropTable(_tableName);

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider   = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);

            _transport = new SqlServerTransport(connectionProvider, _tableName, QueueName, consoleLoggerFactory);
            _transport.EnsureTableIsCreated();

            Using(_transport);

            _transport.Initialize();
        }
Esempio n. 4
0
        public ITransport Create(string inputQueueAddress)
        {
            var tableName = ("RebusMessages_" + TestConfig.Suffix).TrimEnd('_');

            _tablesToDrop.Add(tableName);

            var transport = new SqlServerTransport(new DbConnectionProvider(SqlTestHelper.ConnectionString), tableName, inputQueueAddress);

            _disposables.Add(transport);

            transport.EnsureTableIsCreated();
            transport.Initialize();

            return(transport);
        }
Esempio n. 5
0
        protected override void SetUp()
        {
            SqlTestHelper.DropTable(_tableName);

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider   = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);

            _transport = new SqlServerTransport(connectionProvider, _tableName, QueueName, consoleLoggerFactory, asyncTaskFactory);
            _transport.EnsureTableIsCreated();

            Using(_transport);

            _transport.Initialize();

            _cancellationToken = new CancellationTokenSource().Token;
        }
Esempio n. 6
0
        public ITransport CreateOneWayClient()
        {
            var tableName = ("RebusMessages_" + TestConfig.Suffix).TrimEnd('_');

            _tablesToDrop.Add(tableName);

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider   = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);
            var transport            = new SqlServerTransport(connectionProvider, tableName, null, consoleLoggerFactory);

            _disposables.Add(transport);

            transport.EnsureTableIsCreated();
            transport.Initialize();

            return(transport);
        }
Esempio n. 7
0
        public ITransport Create(string inputQueueAddress)
        {
            var tableName = ("RebusMessages_" + TestConfig.Suffix).TrimEnd('_');

            _tablesToDrop.Add(tableName);

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider   = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);
            var transport            = new SqlServerTransport(connectionProvider, tableName, inputQueueAddress, consoleLoggerFactory, asyncTaskFactory);

            _disposables.Add(transport);

            transport.EnsureTableIsCreated();
            transport.Initialize();

            return(transport);
        }
        protected override void SetUp()
        {
            // start clean
            SqlTestHelper.DropAllTables();

            // end clean
            Using(new DisposableCallback(SqlTestHelper.DropAllTables));

            var loggerFactory      = new ListLoggerFactory();
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            _subscriptionStorage = new SqlServerSubscriptionStorage(connectionProvider, "Subscriptions", isCentralized: true, loggerFactory);
            _subscriptionStorage.EnsureTableIsCreated();
            _subscriptionStorage.Initialize();

            _subscriberTransport = Using(new SqlServerTransport(connectionProvider, "subscriber", loggerFactory, new TplAsyncTaskFactory(loggerFactory), new FakeRebusTime(), new SqlServerTransportOptions(connectionProvider)));
            _subscriberTransport.EnsureTableIsCreated();
            _subscriberTransport.Initialize();
        }