public void TestMethod1() { #if DEBUG var connectionString = ""; int scalecount = 10; //Setting up everything (run Once) var options = new ServiceBusMessageProcessorProviderOptions() { ConnectionString = connectionString, TopicScaleCount = scalecount, CorrelationToQueueMapping = new Dictionary<string, EntityDescription>{ {"test", new QueueDescription("test") }, {"anothertest",new QueueDescription("another-test")} }, //Subscription Description is only used for properties passing to the created subscriptions. here sub is prefixname of forward subscriptions SubscriptionDescription = new SubscriptionDescription("blablanotUsed", "sub"), //Topic is used for properties and topic nameprefix, this case ourtopics. TopicDescription = new TopicDescription("ourTopics"), ConnectionStringProvider = new Dictionary<string, string> { {"test",connectionString}, {"anothertest",connectionString} } }; var provider = new ServiceBusMessageProcessorProvider(options); provider.EnsureTopicsAndQueuesCreatedAsync().Wait(); //This is what is needed to post messages to the system. var anotherProvider = new ServiceBusMessageProcessorProvider( new ServiceBusMessageProcessorProviderOptions { ConnectionString = connectionString, TopicScaleCount = scalecount, CorrelationIdProvider = (message) => { return (message as TestMessage).Id; }, ConnectionStringProvider = new Dictionary<string, string> { {"test",connectionString}, {"anothertest",connectionString} }, TopicDescription = new TopicDescription("ourTopics"), }); for (var i = 0; i < 10; i++) { anotherProvider.SendMessageAsync(new TestMessage { Id = "test", PostMessage = new Test2Message() { Test = "asd", Test2="adsa" } }).Wait(); anotherProvider.SendMessageAsync(new TestMessage { Id = "anothertest" }).Wait(); anotherProvider.SendMessageAsync(new TestMessage { Id = "test" }).Wait(); } #endif }
//private readonly NamespaceManager namespaceManager; public ScaledTopicClient(ServiceBusMessageProcessorProviderOptions options) { // this.options = options; this.R = new Random(); this._scaleCount = options.TopicScaleCount.Value; LazyTopicClients = new Dictionary<string, Lazy<TopicClient>[]>(); if (options.ConnectionStringProvider != null) { foreach (var mapping in options.ConnectionStringProvider) { LazyTopicClients.Add(mapping.Key, CreateTopicClientsForConnectionString(options.TopicScaleCount.Value, options.TopicDescription.Path, mapping.Value)); } } LazyTopicClients.Add(DEFAULT_COORELATION_ID, CreateTopicClientsForConnectionString( options.TopicScaleCount.Value, options.TopicDescription.Path, options.ConnectionString)); }