private ServiceBus CreateServiceBusManager() { var manager = ServiceBus.CreateFromConnectionString(_options.ConnectionString); manager.Settings.OperationTimeout = _options.RemoteOperationTimeout; return(manager); }
/// <summary> /// Instantiate receiving on this bus by /// calling <see cref="CheckPrivateTopicExists"/> and <see cref="CheckPublicTopicExists"/> /// then InstantiateReceiving for private and public topics, /// calls <see cref="CleanUpDeadLetters"/> for the private and public topics, /// then calling <see cref="AzureBus{TAuthenticationToken}.StartSettingsChecking"/> /// </summary> protected override void InstantiateReceiving() { #if NET452 Manager manager = Manager.CreateFromConnectionString(ConnectionString); #endif #if NETSTANDARD2_0 var manager = new Manager(ConnectionString); #endif CheckPrivateTopicExists(manager); CheckPublicTopicExists(manager); try { InstantiateReceiving(manager, PrivateServiceBusReceivers, PrivateTopicName, PrivateTopicSubscriptionName); } catch (UriFormatException exception) { throw new InvalidConfigurationException("The connection string for one of the private Service Bus receivers may be invalid.", exception); } try { InstantiateReceiving(manager, PublicServiceBusReceivers, PublicTopicName, PublicTopicSubscriptionName); } catch (UriFormatException exception) { throw new InvalidConfigurationException("The connection string for one of the public Service Bus receivers may be invalid.", exception); } bool enableDeadLetterCleanUp; string enableDeadLetterCleanUpValue = ConfigurationManager.GetSetting("Cqrs.Azure.Servicebus.EnableDeadLetterCleanUp"); if (bool.TryParse(enableDeadLetterCleanUpValue, out enableDeadLetterCleanUp) && enableDeadLetterCleanUp) { CleanUpDeadLetters(PrivateTopicName, PrivateTopicSubscriptionName); CleanUpDeadLetters(PublicTopicName, PublicTopicSubscriptionName); } // If this is also a publisher, then it will the check over there and that will handle this // we only need to check one of these if (PublicServiceBusPublisher != null) { return; } StartSettingsChecking(); }
/// <summary> /// Instantiate publishing on this bus by /// calling <see cref="CheckPrivateTopicExists"/> and <see cref="CheckPublicTopicExists"/> /// then calling <see cref="AzureBus{TAuthenticationToken}.StartSettingsChecking"/> /// </summary> protected override void InstantiatePublishing() { #if NET452 Manager manager = Manager.CreateFromConnectionString(ConnectionString); #endif #if NETSTANDARD2_0 var manager = new Manager(ConnectionString); #endif CheckPrivateTopicExists(manager); CheckPublicTopicExists(manager); #if NET452 PrivateServiceBusPublisher = TopicClient.CreateFromConnectionString(ConnectionString, PrivateTopicName); PublicServiceBusPublisher = TopicClient.CreateFromConnectionString(ConnectionString, PublicTopicName); #endif #if NETSTANDARD2_0 PrivateServiceBusPublisher = new TopicClient(ConnectionString, PrivateTopicName); PublicServiceBusPublisher = new TopicClient(ConnectionString, PublicTopicName); #endif StartSettingsChecking(); }
/// <summary> /// Instantiate receiving on this bus by /// calling <see cref="CheckPrivateHubExists"/> and <see cref="CheckPublicHubExists"/> /// then InstantiateReceiving for private and public topics, /// then calling <see cref="AzureBus{TAuthenticationToken}.StartSettingsChecking"/> /// </summary> protected override void InstantiateReceiving() { #if NET452 Manager manager = Manager.CreateFromConnectionString(ConnectionString); #endif #if NETSTANDARD2_0 var manager = new Manager(ConnectionString); #endif CheckPrivateHubExists(manager); CheckPublicHubExists(manager); EventHubReceiver = new EventProcessorHost(PublicEventHubName, PublicEventHubConsumerGroupName, ConnectionString, StorageConnectionString, "Cqrs"); // If this is also a publisher, then it will the check over there and that will handle this if (EventHubPublisher != null) { return; } StartSettingsChecking(); }
/// <summary> /// Instantiate publishing on this bus by /// calling <see cref="CheckPrivateHubExists"/> and <see cref="CheckPublicHubExists"/> /// then calling <see cref="AzureBus{TAuthenticationToken}.StartSettingsChecking"/> /// </summary> protected override void InstantiatePublishing() { #if NET452 Manager manager = Manager.CreateFromConnectionString(ConnectionString); #endif #if NETSTANDARD2_0 var manager = new Manager(ConnectionString); #endif CheckPrivateHubExists(manager); CheckPublicHubExists(manager); #if NET452 EventHubPublisher = EventHubClient.CreateFromConnectionString(ConnectionString, PublicEventHubName); #endif #if NETSTANDARD2_0 var connectionStringBuilder = new EventHubsConnectionStringBuilder(ConnectionString) { EntityPath = PublicEventHubName }; EventHubPublisher = EventHubClient.Create(connectionStringBuilder); #endif StartSettingsChecking(); }