public void Should_be_able_to_set_retrypolicy() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); var connectivitySettings = extensions.MessagingFactories().RetryPolicy(RetryPolicy.NoRetry); Assert.IsInstanceOf <NoRetry>(connectivitySettings.GetSettings().Get <RetryPolicy>(WellKnownConfigurationKeys.Connectivity.MessagingFactories.RetryPolicy)); }
public void Should_be_able_to_set_batchflushinterval() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); var connectivitySettings = extensions.MessagingFactories().BatchFlushInterval(TimeSpan.FromSeconds(0)); Assert.AreEqual(TimeSpan.FromSeconds(0), connectivitySettings.GetSettings().Get <TimeSpan>(WellKnownConfigurationKeys.Connectivity.MessagingFactories.BatchFlushInterval)); }
public void Should_be_able_to_set_number_of_messaging_factories_per_namespace() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); var connectivitySettings = extensions.MessagingFactories().NumberOfMessagingFactoriesPerNamespace(4); Assert.AreEqual(4, connectivitySettings.GetSettings().Get <int>(WellKnownConfigurationKeys.Connectivity.MessagingFactories.NumberOfMessagingFactoriesPerNamespace)); }
public void Should_be_able_to_set_messaging_factory_settings_factory_method() { var settings = new SettingsHolder(); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); Func <string, MessagingFactorySettings> registeredFactory = s => new MessagingFactorySettings(); var connectivitySettings = extensions.MessagingFactories().MessagingFactorySettingsFactory(registeredFactory); Assert.AreEqual(registeredFactory, connectivitySettings.GetSettings().Get <Func <string, MessagingFactorySettings> >(WellKnownConfigurationKeys.Connectivity.MessagingFactories.MessagingFactorySettingsFactory)); }
public static void ConfigureTransport(this TransportExtensions <AzureServiceBusTransport> transport, TransportSettings transportSettings) { transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive); transport.ConnectionString(transportSettings.ConnectionString); transport.MessageReceivers().PrefetchCount(0); transport.Queues().LockDuration(TimeSpan.FromMinutes(5)); transport.Subscriptions().LockDuration(TimeSpan.FromMinutes(5)); transport.MessagingFactories().NumberOfMessagingFactoriesPerNamespace(2); transport.NumberOfClientsPerEntity(Math.Min(Environment.ProcessorCount, transportSettings.MaxConcurrency)); }
#pragma warning disable 618 public static void ConfigureTransport(this TransportExtensions <AzureServiceBusTransport> transport, TransportSettings transportSettings, TransportTransactionMode transactionMode) #pragma warning restore 618 { //If the custom part stays in the connection string and is at the end, the sdk will treat is as part of the SharedAccessKey var connectionString = ConnectionStringPartRemover.Remove(transportSettings.ConnectionString, QueueLengthProvider.QueueLengthQueryIntervalPartName); transport.ConnectionString(connectionString); transport.Transactions(transactionMode); transport.Queues().LockDuration(TimeSpan.FromMinutes(5)); transport.Subscriptions().LockDuration(TimeSpan.FromMinutes(5)); transport.MessagingFactories().NumberOfMessagingFactoriesPerNamespace(2); transport.NumberOfClientsPerEntity(Math.Min(Environment.ProcessorCount, transportSettings.MaxConcurrency)); }
public async Task Can_send_batches_of_brokered_messages_fast() { // default settings var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer()); settings.Set(new TopologySettings()); var namespacesDefinition = settings.Get <NamespaceConfigurations>(WellKnownConfigurationKeys.Topology.Addressing.Namespaces); namespacesDefinition.Add("namespace", AzureServiceBusConnectionString.Value, NamespacePurpose.Partitioning); var extensions = new TransportExtensions <AzureServiceBusTransport>(settings); extensions.NumberOfClientsPerEntity(5); extensions.MessagingFactories() .NumberOfMessagingFactoriesPerNamespace(5) .BatchFlushInterval(TimeSpan.FromMilliseconds(0)); // turns of native batching // setup the infrastructure var namespaceManagerCreator = new NamespaceManagerCreator(settings); var namespaceLifecycleManager = new NamespaceManagerLifeCycleManagerInternal(namespaceManagerCreator); var messagingFactoryCreator = new MessagingFactoryCreator(namespaceLifecycleManager, settings); var messagingFactoryLifeCycleManager = new MessagingFactoryLifeCycleManager(messagingFactoryCreator, settings); var messageSenderCreator = new MessageSenderCreator(messagingFactoryLifeCycleManager, settings); var entityLifecycleManager = new MessageSenderLifeCycleManager(messageSenderCreator, settings); var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings); // create the queue var namespaceManager = namespaceLifecycleManager.Get("namespace"); await creator.Create("myqueue", namespaceManager); // perform the test var sw = new Stopwatch(); sw.Start(); var counter = 0; var tasks = new List <Task>(); for (var j = 0; j < 10; j++) { var batch = new List <BrokeredMessage>(); for (var i = 0; i < 1000; i++) { batch.Add(new BrokeredMessage()); counter++; } var sender = await entityLifecycleManager.Get("myqueue", null, "namespace"); tasks.Add(sender.RetryOnThrottleAsync(s => s.SendBatch(batch), s => s.SendBatch(batch.Select(x => x.Clone())), TimeSpan.FromSeconds(10), 5)); } await Task.WhenAll(tasks); //validate sw.Stop(); Console.WriteLine("Sending {1} messages took {0} milliseconds", sw.ElapsedMilliseconds, counter); var faulted = tasks.Count(task => task.IsFaulted); Console.WriteLine("Total of {0} msgs / second", (double)(10000 - faulted) / sw.ElapsedMilliseconds * 1000); Assert.IsTrue(sw.ElapsedMilliseconds < TimeSpan.FromMinutes(1).TotalMilliseconds); //cleanup await namespaceManager.DeleteQueue("myqueue"); }