public async Task NizzleName(int messageCount, bool useNewIndexScript, bool dropOldIndex)
        {
            if (useNewIndexScript)
            {
                SqlTestHelper.Execute(IndexCreationScriptToCheck);

                SqlTestHelper.DropIndex(TableName, $"IDX_RECEIVE_{TableName}");
            }

            Console.WriteLine($"Sending {messageCount} messages...");

            await Task.WhenAll(Enumerable.Range(0, messageCount)
                               .Select(i => _adapter.Bus.SendLocal($"THIS IS MESSAGE {i}")));

            var counter = new SharedCounter(messageCount);

            _adapter.Handle <string>(async message => counter.Decrement());

            Console.WriteLine("Waiting for messages to be received...");

            var stopwtach = Stopwatch.StartNew();

            _adapter.Bus.Advanced.Workers.SetNumberOfWorkers(3);

            counter.WaitForResetEvent(messageCount / 500 + 5);

            var elapsedSeconds = stopwtach.Elapsed.TotalSeconds;

            Console.WriteLine($"{messageCount} messages received in {elapsedSeconds:0.0} s - that's {messageCount / elapsedSeconds:0.0} msg/s");
        }
예제 #2
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()
        {
            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();
        }
    void CreateTriggerThatThrowsExceptionWhenInsertingIntoTable(string queueName)
    {
        var triggerName = $"FailMessageTrigger_{queueName}";
        var sql         = $@"

CREATE OR ALTER TRIGGER [dbo].[{triggerName}] ON [dbo].[{queueName}]
AFTER INSERT
AS 
BEGIN
    BEGIN
        THROW 51000, 'THIS IS THE INSERT TRIGGER FAILING ON PURPOSE', 1;  
    END
END
";

        SqlTestHelper.Execute(sql);

        Using(new DisposableCallback(() => SqlTestHelper.Execute($"DROP TRIGGER [dbo].[{triggerName}]")));
    }
        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
	)
)

");
        }