/// <summary> /// Checks if a given topic exists to facilitate tests that scorch the namespace and check if the topic was properly created. /// </summary> /// <param name="sbNamespace">The <see cref="IServiceBusNamespace"/> that we are checking in.</param> /// <param name="topicName">The topic name we are checking for</param> /// <param name="subscriptionName">The name of the subscription that we are checking on the topic.</param> public static void AssertSubscriptionDoNotExists(this IServiceBusNamespace sbNamespace, string topicName, string subscriptionName) { sbNamespace.Refresh(); var subscriptions = sbNamespace.Topics.GetByName(topicName).Subscriptions.List().ToList(); subscriptions.Should().NotBeNull().And.BeEmpty(); }
public UICommandService(IConfiguration configuration) { _configuration = configuration; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); EnsureTopicIsCreated(); }
public ProductionAreaChanged(IMapper mapper, IConfiguration configuration) { _mapper = mapper; _configuration = configuration; _namespace = _configuration.GetServiceBusNamespace(); EnsureTopicIsCreated(); }
/// <summary> /// Attempts to refresh the stored <see cref="IServiceBusNamespace"/> fluent construct. /// Will do a full rebuild if any type of failure occurs during the refresh. /// </summary> /// <returns>The refreshed <see cref="IServiceBusNamespace"/>.</returns> internal async Task <IServiceBusNamespace> GetRefreshedServiceBusNamespace() { try { if (AzureServiceBusNamespace != null) { return(await AzureServiceBusNamespace.RefreshAsync().ConfigureAwait(false)); } } catch { /* soak */ } var token = await new AzureServiceTokenProvider().GetAccessTokenAsync("https://management.core.windows.net/", string.Empty).ConfigureAwait(false); var tokenCredentials = new TokenCredentials(token); var client = RestClient.Configure() .WithEnvironment(AzureEnvironment.AzureGlobalCloud) .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic) .WithCredentials(new AzureCredentials(tokenCredentials, tokenCredentials, string.Empty, AzureEnvironment.AzureGlobalCloud)) .Build(); AzureServiceBusNamespace = (await Azure.Authenticate(client, string.Empty) .WithSubscription(SubscriptionId) .ServiceBusNamespaces.ListAsync() .ConfigureAwait(false)) .SingleOrDefault(n => n.Name == NamespaceName); if (AzureServiceBusNamespace == null) { throw new InvalidOperationException($"Couldn't find the service bus namespace {NamespaceName} in the subscription with ID {SubscriptionId}"); } return(AzureServiceBusNamespace); }
public LabelImageAddedService(IConfiguration configuration, IServiceProvider serviceProvider) { this.configuration = configuration; this.serviceProvider = serviceProvider; this.serviceBusNamespace = configuration.GetServiceBusNamespace(); subscriptioncreated = CreateSubscription(); }
public ServiceBusService(IConfiguration configuration) { _configuration = configuration; _serviceBusConfiguration = _configuration.GetSection("servicebus").Get <ServiceBusConfiguration>(); _namespace = _configuration.GetServiceBusNamespace(); _cancelMessages = new CancellationTokenSource(); }
public OrderPaidService(IConfiguration configuration, IOrderChangedService orderChangedService, ILogService logService) { _configuration = configuration; _namespace = _configuration.GetServiceBusNamespace(); _orderChangedService = orderChangedService; _logService = logService; }
public void Setup() { _serviceBusNamespace = A.Fake <IServiceBusNamespace>(); _queueClient = A.Fake <IQueueClient>(); var serviceBusNamespaceFactory = A.Fake <IServiceBusNamespaceFactory>(); var queueClientFactory = A.Fake <IQueueClientFactory>(); A.CallTo(() => serviceBusNamespaceFactory.Create()) .Returns(_serviceBusNamespace); A.CallTo(() => queueClientFactory.Create(A <string> .Ignored)) .Returns(_queueClient); _commandQueueClient = new ServiceBusCommandQueueClient( new Dictionary <string, Type>() { { typeof(TestingCommand).Name, typeof(TestingCommand) } }, serviceBusNamespaceFactory, queueClientFactory); A.CallTo(() => _queueClient.RegisterMessageHandler( A <Func <Message, CancellationToken, Task> > .Ignored, A <MessageHandlerOptions> .Ignored)) .Invokes((Func <Message, CancellationToken, Task> callback, MessageHandlerOptions options) => _messageHandler = callback); }
/// <summary> /// Create resource /// </summary> /// <param name="manager"></param> /// <param name="resourceGroup"></param> /// <param name="nameSpace"></param> /// <param name="result"></param> /// <param name="logger"></param> public ServiceBusResource(ServiceBusFactory manager, IResourceGroupResource resourceGroup, IServiceBusNamespace nameSpace, Dictionary <string, IAuthorizationKeys> result, ILogger logger) { _resourceGroup = resourceGroup; _nameSpace = nameSpace; _manager = manager; _logger = logger; if (result.TryGetValue("manage", out var key)) { PrimaryManageConnectionString = key.PrimaryConnectionString; SecondaryManageConnectionString = key.SecondaryConnectionString; } if (result.TryGetValue("listen", out key)) { PrimaryListenConnectionString = key.PrimaryConnectionString; SecondaryListenConnectionString = key.SecondaryConnectionString; } if (result.TryGetValue("send", out key)) { PrimarySendConnectionString = key.PrimaryConnectionString; SecondarySendConnectionString = key.SecondaryConnectionString; } }
public UIServiceBus(IOptions <ServiceBusOptions> configuration) { _configuration = configuration.Value; _messages = new List <Message>(); _namespace = ServiceBusNamespaceExtension.GetServiceBusNamespace(_configuration); EnsureTopicIsCreated(); }
/// <summary> /// Creates a specific queue if it doesn't exist in the target namespace. /// </summary> /// <param name="sbNamespace">The <see cref="IServiceBusNamespace"/> where we are creating the queue in.</param> /// <param name="name">The name of the queue that we are looking for.</param> /// <returns>The <see cref="IQueue"/> entity object that references the Azure queue.</returns> public static async Task <IQueue> CreateQueueIfNotExists(this IServiceBusNamespace sbNamespace, string name) { var queue = await sbNamespace.GetQueueByNameAsync(name); if (queue != null) { return(queue); } try { return(await sbNamespace.Queues .Define(name.ToLowerInvariant()) .WithMessageLockDurationInSeconds(60) .WithDuplicateMessageDetection(TimeSpan.FromMinutes(10)) .WithExpiredMessageMovedToDeadLetterQueue() .WithMessageMovedToDeadLetterQueueOnMaxDeliveryCount(10) .CreateAsync()); } catch (CloudException ce) when(ce.Response.StatusCode == HttpStatusCode.BadRequest && ce.Message.Contains("SubCode=40000. The value for the requires duplicate detection property of an existing Queue cannot be changed")) { // Create queue race condition occurred. Return existing queue. return(await sbNamespace.GetQueueByNameAsync(name)); } }
/// <summary> /// Checks if a given topic exists to facilitate tests that scorch the namespace and check if the topic was properly created. /// </summary> /// <param name="sbNamespace">The <see cref="IServiceBusNamespace"/> that we are checking in.</param> /// <param name="topicName">The topic name</param> public static void AssertSingleTopicExists(this IServiceBusNamespace sbNamespace, string topicName) { sbNamespace.Refresh(); var topics = sbNamespace.Topics.List().ToList(); topics.Count.Should().Be(1); topics.SingleOrDefault(s => string.Equals(s.Name, topicName, StringComparison.CurrentCultureIgnoreCase)).Should().NotBeNull(); }
public LogService(IMapper mapper, IConfiguration configuration) { _mapper = mapper; _configuration = configuration; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); EnsureTopicIsCreated(); }
/// <summary> /// Checks if a given topic exists to facilitate tests that scorch the namespace and check if the topic was properly created. /// </summary> /// <param name="sbNamespace">The <see cref="IServiceBusNamespace"/> that we are checking in.</param> /// <param name="topicName">The topic name we are checking for</param> /// <param name="subscriptionName">The name of the subscription that we are checking on the topic.</param> public static void AssertSingleTopicSubscriptionExists(this IServiceBusNamespace sbNamespace, string topicName, string subscriptionName) { sbNamespace.Refresh(); var subscriptions = sbNamespace.Topics.GetByName(topicName).Subscriptions.List().ToList(); subscriptions.Count.Should().Be(1); subscriptions.SingleOrDefault(t => string.Equals(t.Name, subscriptionName, StringComparison.CurrentCultureIgnoreCase)).Should().NotBeNull(); }
public ServiceBusService() { var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(Constant.CLIENT_ID, Constant.CLIENT_SECRET, Constant.TENANT_ID, AzureEnvironment.AzureGlobalCloud); var serviceBusManager = ServiceBusManager.Authenticate(credentials, Constant.SUBSCRIPTION_ID); serviceBusNamespace = serviceBusManager.Namespaces.GetByResourceGroup(Constant.RESOURCE_GROUP, Constant.RESOURCE_NAME); }
public ServiceBusSub(IConfiguration configuration, ILogService logService) { _configuration = configuration; _logService = logService; _namespace = _configuration.GetServiceBusNamespace(); EnsureTopicIsCreated(); EnsureSubscriptionsIsCreated(); }
/// <summary> /// Checks if a given queue exists to facilitate tests that scorch the namespace and check if the queue was properly created. /// </summary> /// <param name="sbNamespace">The <see cref="IServiceBusNamespace"/> that we are checking in.</param> /// <param name="type">The message <see cref="Type"/> that we are checking the queue for.</param> public static void AssertSingleQueueExists(this IServiceBusNamespace sbNamespace, Type type) { sbNamespace.Refresh(); var queues = sbNamespace.Queues.List().ToList(); queues.Count.Should().Be(1); queues.SingleOrDefault(q => string.Equals(q.Name, type.GetEntityName(), StringComparison.CurrentCultureIgnoreCase)).Should().NotBeNull(); }
public SendIngredientsService(IConfiguration configuration, ILogger <SendIngredientsService> logger) { _configuration = configuration; _logger = logger; _serviceBusNamespace = _configuration.GetServiceBusNamespace(); _queuename = _configuration.GetSection("serviceBus:queueName").Value; _connectionString = _configuration.GetSection("serviceBus:connectionString").Value; }
public UserWithLessOffer(IMapper mapper, IConfiguration configuration, ILogService logService) { _mapper = mapper; _configuration = configuration; _logService = logService; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); EnsureTopicIsCreated(); }
private static async Task <ITopic> FindOrCreateTopic(IServiceBusNamespace nameSpace, string name) { System.Console.WriteLine("Find or Create Topic {0}", name); var topics = await nameSpace.Topics.ListAsync(); Dump(topics); return(await nameSpace.Topics.Define(name).CreateAsync()); }
public ProductionAreaChangedService(IMapper mapper, IConfiguration configuration, ILogService logService) { _mapper = mapper; _configuration = configuration; _logService = logService; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); EnsureTopicIsCreated(); }
public ReceiveMessagesService(IOptions <ServiceBusOptions> configuration, ILogger logger) { _logger = logger; _configuration = configuration.Value; _namespace = ServiceBusNamespaceExtension.GetServiceBusNamespace(_configuration); EnsureTopicIsCreated(); EnsureSubscriptionsIsCreated(); }
private void CreateTopicIfMissing(string topicName, Type messageType, IServiceBusNamespace @namespace) { var topic = @namespace.Topics.List().FirstOrDefault(x => x.Name == topicName); if (topic == null) { _settings.AzureTopicBuilder(@namespace.Topics.Define(topicName), messageType); } }
public ProductChangedService(IServiceProvider serviceProvider, IMapper mapper, IConfiguration configuration, ILogService logService) { _provider = serviceProvider; _mapper = mapper; _configuration = configuration; _namespace = _configuration.GetServiceBusNamespace(); _logService = logService; EnsureTopicIsCreated(); }
public StoreCatalogReadyService(IMapper mapper, IConfiguration configuration, ILogService logService) { _mapper = mapper; _configuration = configuration; _logService = logService; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); EnsureTopicIsCreated(); }
public NewOrderService(IMapper mapper, IConfiguration configuration, IOrderChangedService orderChanged) { _mapper = mapper; _configuration = configuration; _orderChanged = orderChanged; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); EnsureTopicIsCreated(); }
public ProductionAreaChangedService( IConfiguration configuration, ILogService logService, IServiceProvider serviceProvider) { _configuration = configuration; _logService = logService; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); _cancelMessages = new CancellationTokenSource(); _serviceProvider = serviceProvider; }
public ShowDisplayService(IConfiguration configuration, ILogService logService, IServiceProvider serviceProvider) { //_mapper = mapper; _configuration = configuration; _logService = logService; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); _cancelMessages = new CancellationTokenSource(); _serviceProvider = serviceProvider; }
public async Task Setup() { _configuration = new ServiceBusTestConfiguration(); _serviceBusNamespace = await GetNamespace(_configuration); _commandQueueClient = new ServiceBusCommandQueueClient( new Dictionary <string, Type>(), new ServiceBusNamespaceFactory(_configuration), new QueueClientFactory(_configuration)); }
public LabelLoaderChangedService(IMapper mapper, IConfiguration configuration, ILogService logService, IServiceProvider serviceProvider) { _mapper = mapper; _configuration = configuration; _logService = logService; _messages = new List <Message>(); _namespace = _configuration.GetServiceBusNamespace(); _cancelMessages = new CancellationTokenSource(); _serviceProvider = serviceProvider; }