Exemplo n.º 1
0
        static SqlServerSubscriptionStorage GetStorage(bool createCustomSchema)
        {
            SqlTestHelper.DropTable("Subscriptions");

            var loggerFactory      = new ConsoleLoggerFactory(false);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);
            var storage            = new SqlServerSubscriptionStorage(connectionProvider, "Subscriptions", true, loggerFactory);

            if (createCustomSchema)
            {
                var tableName = TableName.Parse("Subscriptions");

                SqlTestHelper.Execute($@"

    CREATE TABLE {tableName.QualifiedName} (
	    [topic] [nvarchar](350) NOT NULL,
	    [address] [nvarchar](50) NOT NULL,
        CONSTRAINT [PK_{tableName.Schema}_{tableName.Name}] PRIMARY KEY CLUSTERED 
        (
	        [topic] ASC,
	        [address] ASC
        )
    )

");
            }
            else
            {
                storage.EnsureTableIsCreated();
            }

            storage.Initialize();

            return(storage);
        }
    protected override void SetUp()
    {
        base.SetUp();

        SqlTestHelper.DropTable("RebusOutbox");

        _network         = new InMemNetwork();
        _subscriberStore = new InMemorySubscriberStore();
    }
Exemplo n.º 3
0
        protected override void SetUp()
        {
            SqlTestHelper.DropTable(_tableName);

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

            Using(_transport);

            _transport.Initialize();
        }
Exemplo n.º 4
0
        protected override void SetUp()
        {
            var loggerFactory      = new ConsoleLoggerFactory(false);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            var tableName = TestConfig.QueueName("data");

            SqlTestHelper.DropTable(tableName);

            _storage = new SqlServerDataBusStorage(connectionProvider, tableName, true, loggerFactory);
            _storage.Initialize();
        }
Exemplo n.º 5
0
        public void CleanUp()
        {
            _disposables.ForEach(d => d.Dispose());
            _disposables.Clear();

            foreach (var table in _tablesToDrop)
            {
                SqlTestHelper.DropTable(table);
            }

            _tablesToDrop.Clear();
        }
Exemplo n.º 6
0
        protected override void SetUp()
        {
            var loggerFactory = new ConsoleLoggerFactory(false);

            _connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            _dataTableName  = TestConfig.GetName("sagas");
            _indexTableName = TestConfig.GetName("sagaindex");

            SqlTestHelper.DropTable(_indexTableName);
            SqlTestHelper.DropTable(_dataTableName);

            _storage = new SqlServerSagaStorage(_connectionProvider, _dataTableName, _indexTableName, loggerFactory);
        }
Exemplo n.º 7
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();
        }
        protected override void SetUp()
        {
            var loggerFactory      = new ConsoleLoggerFactory(false);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            var dataTableName  = TestConfig.QueueName("sagas");
            var indexTableName = TestConfig.QueueName("sagaindex");

            SqlTestHelper.DropTable(indexTableName);
            SqlTestHelper.DropTable(dataTableName);

            _storage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, loggerFactory);

            _storage.EnsureTablesAreCreated();
        }
        protected override void SetUp()
        {
            SqlTestHelper.Execute($"alter database [{SqlTestHelper.DatabaseName}] set allow_snapshot_isolation on");

            Using(new DisposableCallback(() => SqlTestHelper.Execute($"alter database [{SqlTestHelper.DatabaseName}] set allow_snapshot_isolation off")));

            _queueName = TestConfig.GetName("test-queue");

            SqlTestHelper.DropTable(_queueName);

            var transport = GetTransport(SqlTestHelper.ConnectionString, IsolationLevel.ReadCommitted);

            Using(transport);

            transport.EnsureTableIsCreated();
        }
        protected override void SetUp()
        {
            SqlTestHelper.DropTable("Messages");

            _activator = new BuiltinHandlerActivator();

            Using(_activator);

            _bus = Configure.With(_activator)
                   .Transport(t => t.UseSqlServer(SqlTestHelper.ConnectionString, "Messages", QueueName))
                   .Options(o =>
            {
                o.LogPipeline();
            })
                   .Start();
        }
Exemplo n.º 11
0
        protected override void SetUp()
        {
            SqlTestHelper.DropTable(TableName);

            _activator = Using(new BuiltinHandlerActivator());

            Configure.With(_activator)
            .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "auditing-buggerino"))
            .Sagas(s => s.StoreInMemory())
            .Options(o =>
            {
                o.EnableSagaAuditing().StoreInSqlServer(SqlTestHelper.ConnectionString, TableName);
                o.SetMaxParallelism(1);
            })
            .Start();
        }
Exemplo n.º 12
0
        protected override void SetUp()
        {
            var loggerFactory = new ConsoleLoggerFactory(false);

            _connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);
            var sagaTypeNamingStrategy = new LegacySagaTypeNamingStrategy();
            var serializer             = new DefaultSagaSerializer();

            _dataTableName  = TestConfig.GetName("sagas");
            _indexTableName = TestConfig.GetName("sagaindex");

            SqlTestHelper.DropTable(_indexTableName);
            SqlTestHelper.DropTable(_dataTableName);

            _storage = new SqlServerSagaStorage(_connectionProvider, _dataTableName, _indexTableName, loggerFactory, sagaTypeNamingStrategy, serializer);
        }
        protected override void SetUp()
        {
            SqlTestHelper.DropTable(TableName);

            _adapter = Using(new BuiltinHandlerActivator());

            Configure.With(_adapter)
            .Logging(l => l.ColoredConsole(LogLevel.Warn))
            .Transport(t => t.UseSqlServer(SqlTestHelper.ConnectionString, TableName, QueueName))
            .Options(o =>
            {
                o.SetNumberOfWorkers(0);
                o.SetMaxParallelism(20);
            })
            .Start();
        }
Exemplo n.º 14
0
    protected override void SetUp()
    {
        SqlTestHelper.DropTable("Messages");

        _activator = new BuiltinHandlerActivator();

        Using(_activator);

        _starter = Configure.With(_activator)
                   .Transport(t => t.UseSqlServer(new SqlServerTransportOptions(SqlTestHelper.ConnectionString), QueueName))
                   .Routing(r => r.TypeBased().Map <TimedMessage>(QueueName))
                   .Options(o =>
        {
            o.LogPipeline();
        })
                   .Create();
    }
Exemplo n.º 15
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;
        }
Exemplo n.º 16
0
        protected override void SetUp()
        {
            SqlTestHelper.DropTable("RebusMessages");

            _handlerActivator = new BuiltinHandlerActivator();

            _bus = Configure.With(_handlerActivator)
                   .Transport(x => x.UseSqlServer(ConnectionString, "RebusMessages", "test.input"))
                   .Sagas(x => x.StoreInSqlServer(ConnectionString, "Sagas", "SagaIndex"))
                   .Options(x =>
            {
                x.SetNumberOfWorkers(1);
                x.SetMaxParallelism(1);
            })
                   .Start();

            Using(_bus);
        }
Exemplo n.º 17
0
        protected override void SetUp()
        {
            SqlTestHelper.DropTable("subscriptions");

            var network = new InMemNetwork();

            _publisher = GetEndpoint(network, "publisher", c =>
            {
                c.Subscriptions(s => s.StoreInSqlServer(SqlTestHelper.ConnectionString, "subscriptions"));
                c.Routing(r => r.TypeBased());
            });

            _client1GotTheEvent = new ManualResetEvent(false);
            _client1            = GetEndpoint(network, "client1", c =>
            {
                c.Routing(r => r.TypeBased().Map <SomeKindOfEvent>("publisher"));
            });
            _client1.Handle <SomeKindOfEvent>(async e => _client1GotTheEvent.Set());
        }
    IBus CreateBus(
        string queueName,
        Action <BuiltinHandlerActivator> handlers = null,
        Action <TypeBasedRouterConfigurationExtensions.TypeBasedRouterConfigurationBuilder> routing = null
        )
    {
        Using(new DisposableCallback(() => SqlTestHelper.DropTable(queueName)));

        var activator = Using(new BuiltinHandlerActivator());

        handlers?.Invoke(activator);

        Configure.With(activator)
        .Transport(t => t.UseSqlServerInLeaseMode(new SqlServerLeaseTransportOptions(SqlTestHelper.ConnectionString), queueName))
        .Routing(r => routing?.Invoke(r.TypeBased()))
        .Start();

        return(activator.Bus);
    }
Exemplo n.º 19
0
        protected override void SetUp()
        {
            _activator = new BuiltinHandlerActivator();

            Using(_activator);

            SqlTestHelper.DropTable(_indexTableName);
            SqlTestHelper.DropTable(_dataTableName);

            Configure.With(_activator)
            .Logging(l => l.Console(LogLevel.Warn))
            .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "saga-perf"))
            .Sagas(s => s.StoreInSqlServer(SqlTestHelper.ConnectionString, _dataTableName, _indexTableName))
            .Options(o =>
            {
                o.SetNumberOfWorkers(1);
                o.SetMaxParallelism(1);
            })
            .Start();
        }
Exemplo n.º 20
0
        public ITransport Create(string inputQueueAddress)
        {
            var tableName = ("RebusMessages_" + TestConfig.Suffix).TrimEnd('_');

            SqlTestHelper.DropTable(tableName);

            _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, inputQueueAddress, consoleLoggerFactory, asyncTaskFactory);

            _disposables.Add(transport);

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

            return(transport);
        }
Exemplo n.º 21
0
        public ITransport CreateOneWayClient()
        {
            var tableName = ("RebusMessages_" + TestConfig.Suffix).TrimEnd('_');

            SqlTestHelper.DropTable(tableName);

            _tablesToDrop.Add(tableName);

            var rebusTime            = new DefaultRebusTime();
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider   = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);
            var transport            = new SqlServerLeaseTransport(connectionProvider, null, consoleLoggerFactory,
                                                                   asyncTaskFactory, rebusTime, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(2), () => Environment.MachineName, new SqlServerLeaseTransportOptions(connectionProvider));

            _disposables.Add(transport);

            transport.Initialize();

            return(transport);
        }
Exemplo n.º 22
0
        public IBus GetBus <TMessage>(string inputQueueAddress, Func <TMessage, Task> handler)
        {
            var builtinHandlerActivator = new BuiltinHandlerActivator();

            builtinHandlerActivator.Handle(handler);

            var tableName = "messages" + TestConfig.Suffix;

            SqlTestHelper.DropTable(tableName);

            var bus = Configure.With(builtinHandlerActivator)
                      .Transport(t => t.UseSqlServer(SqlTestHelper.ConnectionString, tableName, inputQueueAddress))
                      .Options(o =>
            {
                o.SetNumberOfWorkers(10);
                o.SetMaxParallelism(10);
            })
                      .Start();

            _stuffToDispose.Add(bus);

            return(bus);
        }
        protected override void SetUp()
        {
            SqlTestHelper.DropTable(TableName);

            SqlTestHelper.Execute(@"

CREATE TABLE [dbo].[Messages](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[recipient] [nvarchar](200) NOT NULL,
	[priority] [int] NOT NULL,
	[expiration] [datetime2](7) NOT NULL,
	[visible] [datetime2](7) NOT NULL,
	[headers] [varbinary](max) NOT NULL,
	[body] [varbinary](max) NOT NULL,
	CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED 
	(
		[recipient] ASC,
		[priority] ASC,
		[id] ASC
	)
)

");
        }
Exemplo n.º 24
0
 public SqlServerDataBusStorageFactory()
 {
     SqlTestHelper.DropTable("databus");
 }
Exemplo n.º 25
0
 public void CleanUp()
 {
     SqlTestHelper.DropTable("databus");
 }
Exemplo n.º 26
0
 public void CleanUp()
 {
     SqlTestHelper.DropTable(IndexTableName);
     SqlTestHelper.DropTable(DataTableName);
 }
Exemplo n.º 27
0
 public void Cleanup()
 {
     SqlTestHelper.DropTable(TableName);
 }
 public SqlServerSnapshotStorageFactory()
 {
     SqlTestHelper.DropTable(TableName);
 }
Exemplo n.º 29
0
 protected override void TearDown()
 {
     SqlTestHelper.DropTable(_indexTableName);
     SqlTestHelper.DropTable(_dataTableName);
 }
Exemplo n.º 30
0
 protected override void TearDown()
 {
     SqlTestHelper.DropTable("RebusMessages");
 }