Exemple #1
0
        public async Task Should_start_stop_and_start()
        {
            ServiceBusTokenProviderSettings settings = new TestAzureServiceBusAccountSettings();
            var serviceBusNamespace = Configuration.ServiceNamespace;

            var serviceUri = AzureServiceBusEndpointUriCreator.Create(
                serviceBusNamespace,
                "MassTransit.Azure.ServiceBus.Core.Tests"
                );
            var bus = MassTransit.Bus.Factory.CreateUsingAzureServiceBus(cfg =>
            {
                cfg.Host(serviceUri, h =>
                {
                    h.SharedAccessSignature(s =>
                    {
                        s.KeyName         = settings.KeyName;
                        s.SharedAccessKey = settings.SharedAccessKey;
                        s.TokenTimeToLive = settings.TokenTimeToLive;
                        s.TokenScope      = settings.TokenScope;
                    });
                });

                ConfigureBusDiagnostics(cfg);

                cfg.ReceiveEndpoint("queue01", ep => ep.Consumer(() => new Consumer <Foo01>()));
                cfg.ReceiveEndpoint("queue02", ep => ep.Consumer(() => new Consumer <Foo02>()));
                cfg.ReceiveEndpoint("queue03", ep => ep.Consumer(() => new Consumer <Foo03>()));
                cfg.ReceiveEndpoint("queue04", ep => ep.Consumer(() => new Consumer <Foo04>()));
                cfg.ReceiveEndpoint("queue05", ep => ep.Consumer(() => new Consumer <Foo05>()));
                cfg.ReceiveEndpoint("queue06", ep => ep.Consumer(() => new Consumer <Foo06>()));
                cfg.ReceiveEndpoint("queue07", ep => ep.Consumer(() => new Consumer <Foo07>()));
                cfg.ReceiveEndpoint("queue08", ep => ep.Consumer(() => new Consumer <Foo08>()));
                cfg.ReceiveEndpoint("queue09", ep => ep.Consumer(() => new Consumer <Foo09>()));

                cfg.ReceiveEndpoint("queue10", ep => ep.Consumer(() => new Consumer <Foo10>()));
                cfg.ReceiveEndpoint("queue11", ep => ep.Consumer(() => new Consumer <Foo11>()));
                cfg.ReceiveEndpoint("queue12", ep => ep.Consumer(() => new Consumer <Foo12>()));
                cfg.ReceiveEndpoint("queue13", ep => ep.Consumer(() => new Consumer <Foo13>()));
                cfg.ReceiveEndpoint("queue14", ep => ep.Consumer(() => new Consumer <Foo14>()));
                cfg.ReceiveEndpoint("queue15", ep => ep.Consumer(() => new Consumer <Foo15>()));
                cfg.ReceiveEndpoint("queue16", ep => ep.Consumer(() => new Consumer <Foo16>()));
                cfg.ReceiveEndpoint("queue17", ep => ep.Consumer(() => new Consumer <Foo17>()));
                cfg.ReceiveEndpoint("queue18", ep => ep.Consumer(() => new Consumer <Foo18>()));
                cfg.ReceiveEndpoint("queue19", ep => ep.Consumer(() => new Consumer <Foo19>()));

                cfg.ReceiveEndpoint("queue20", ep => ep.Consumer(() => new Consumer <Foo20>()));
                cfg.ReceiveEndpoint("queue21", ep => ep.Consumer(() => new Consumer <Foo21>()));
                cfg.ReceiveEndpoint("queue22", ep => ep.Consumer(() => new Consumer <Foo22>()));
                cfg.ReceiveEndpoint("queue23", ep => ep.Consumer(() => new Consumer <Foo23>()));
                cfg.ReceiveEndpoint("queue24", ep => ep.Consumer(() => new Consumer <Foo24>()));
                cfg.ReceiveEndpoint("queue25", ep => ep.Consumer(() => new Consumer <Foo25>()));
                cfg.ReceiveEndpoint("queue26", ep => ep.Consumer(() => new Consumer <Foo26>()));
                cfg.ReceiveEndpoint("queue27", ep => ep.Consumer(() => new Consumer <Foo27>()));
                cfg.ReceiveEndpoint("queue28", ep => ep.Consumer(() => new Consumer <Foo28>()));
                cfg.ReceiveEndpoint("queue29", ep => ep.Consumer(() => new Consumer <Foo29>()));
                cfg.ReceiveEndpoint("queue30", ep => ep.Consumer(() => new Consumer <Foo30>()));
            });

            await bus.StartAsync(TestCancellationToken);

            try
            {
            }
            finally
            {
                await bus.StopAsync(TestCancellationToken);
            }

            await bus.StartAsync(TestCancellationToken);

            try
            {
            }
            finally
            {
                await bus.StopAsync(TestCancellationToken);
            }
        }
Exemple #2
0
        public async Task Should_update_the_filter_expression()
        {
            var topicName        = "masstransit.azure.servicebus.core.tests.topologytesttypes/messagea";
            var subscriptionName = "input-message-a";

            var managementClient = Configuration.GetManagementClient();

            await managementClient.DeleteTopicAsync(topicName);

            ServiceBusTokenProviderSettings settings = new TestAzureServiceBusAccountSettings();

            var serviceUri = AzureServiceBusEndpointUriCreator.Create(Configuration.ServiceNamespace);

            var bus = Bus.Factory.CreateUsingAzureServiceBus(x =>
            {
                BusTestFixture.ConfigureBusDiagnostics(x);
                x.Host(serviceUri, h =>
                {
                    h.SharedAccessSignature(s =>
                    {
                        s.KeyName         = settings.KeyName;
                        s.SharedAccessKey = settings.SharedAccessKey;
                        s.TokenTimeToLive = settings.TokenTimeToLive;
                        s.TokenScope      = settings.TokenScope;
                    });
                });

                x.ReceiveEndpoint("subscription-input-queue", e =>
                {
                    e.Subscribe <MessageA>(subscriptionName, s => s.Filter = new SqlFilter("0 = 1"));
                });
            });

            var busHandle = await bus.StartAsync();

            await busHandle.StopAsync(new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);

            IList <RuleDescription> rules = await managementClient.GetRulesAsync(topicName, subscriptionName);

            Assert.That(rules.Count, Is.EqualTo(1));
            Assert.That(rules[0].Filter, Is.InstanceOf <SqlFilter>());

            var filter = rules[0].Filter as SqlFilter;

            Assert.That(filter.SqlExpression, Is.EqualTo("0 = 1"));

            bus = Bus.Factory.CreateUsingAzureServiceBus(x =>
            {
                BusTestFixture.ConfigureBusDiagnostics(x);
                x.Host(serviceUri, h =>
                {
                    h.SharedAccessSignature(s =>
                    {
                        s.KeyName         = settings.KeyName;
                        s.SharedAccessKey = settings.SharedAccessKey;
                        s.TokenTimeToLive = settings.TokenTimeToLive;
                        s.TokenScope      = settings.TokenScope;
                    });
                });

                x.ReceiveEndpoint("subscription-input-queue", e =>
                {
                    e.Subscribe <MessageA>(subscriptionName, s => s.Filter = new SqlFilter("1 = 1"));
                });
            });

            busHandle = await bus.StartAsync();

            await busHandle.StopAsync(new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);

            rules = await managementClient.GetRulesAsync(topicName, subscriptionName);

            Assert.That(rules.Count, Is.EqualTo(1));
            Assert.That(rules[0].Filter, Is.InstanceOf <SqlFilter>());

            filter = rules[0].Filter as SqlFilter;
            Assert.That(filter.SqlExpression, Is.EqualTo("1 = 1"));
        }