public TestableServiceBus(IServiceBusSettings settings, INamespaceManagerBuilder managerBuilder #if USE_MESSAGING_FACTORY , IMessagingFactoryBuilder factoryBuilder #endif ) : base(settings, managerBuilder #if USE_MESSAGING_FACTORY , factoryBuilder #endif ) { }
public void CreateConnection(IServiceBusSettings serviceBusSettings, IServiceSettings serviceSettings, bool declareExchange = true) { //TODO: investigate these settings for better reliability. var factory = _serviceBusConnectionFactory.CreateConnectionFactory(serviceBusSettings.HostName); factory.AutomaticRecoveryEnabled = true; var connection = factory.CreateConnection(); _connection.RegisterConnection(connection); _connection.ServiceSetting = serviceSettings; if (declareExchange) { var exchange = _serviceBusExchangeFactory.CreateServiceBusExchange(); exchange.CreateExchange(serviceSettings.Name, "topic"); } _logger.LogInformation("Connection made to rabbit MQ bus."); _serviceSettings.Name = serviceSettings.Name; }
public ServiceBus( IServiceBusSettings settings, INamespaceManagerBuilder managerBuilder #if USE_MESSAGING_FACTORY , IMessagingFactoryBuilder factoryBuilder #endif ) { _settings = settings; _manager = managerBuilder .CreateNamespaceBuilder() .WithConnectionString(_settings.AzureServiceBusConnectionString) .Build(); #if USE_MESSAGING_FACTORY _messagingFactory = factoryBuilder .CreateMessagingFactoryBuilder() .WithConnectionString(_settings.AzureServiceBusConnectionString) .Build(); #endif }
public static IServiceCollection ConfigureServiceBus(this IServiceCollection services, IServiceBusSettings settings) { var managementClient = new ManagementClient(settings.ConnectionString); IServiceBusManagementClient serviceBusManagementClient = new ServiceBusManagementClient(managementClient); services.AddSingleton(managementClient); services.AddSingleton(serviceBusManagementClient); services.AddSingleton <IQueueClient>(new QueueClient(settings.ConnectionString, settings.QueueName)); services.AddSingleton <ITopicClient>(new TopicClient(settings.ConnectionString, settings.TopicName)); services.AddSingleton <ISubscriptionClient>(new SubscriptionClient(settings.ConnectionString, settings.TopicName, settings.SubscriptionName)); services.AddSingleton <IServiceBusClient, ServiceBusClient>(); serviceBusManagementClient.CreateQueue(settings.QueueName).Wait(); serviceBusManagementClient.CreateTopic(settings.TopicName).Wait(); serviceBusManagementClient.CreateSubscription(settings.TopicName, settings.SubscriptionName, settings.Filters).Wait(); return(services); }