public AsbService(IUserService userService,
                          ServiceBusErrorManagementSettings serviceBusSettings,
                          ILogger <AsbService> logger,
                          IServiceBusPolicies serviceBusPolicies)
        {
            _logger      = logger ?? throw new Exception("logger is null");
            _regexString = serviceBusSettings.QueueSelectionRegex;
            _userService = userService;
            _policies    = serviceBusPolicies;

            _sbConnectionStringBuilder = new ServiceBusConnectionStringBuilder(serviceBusSettings.ServiceBusConnectionString);
            _tokenProvider             = TokenProvider.CreateManagedIdentityTokenProvider();
            _managementClient          = _sbConnectionStringBuilder.HasSasKey()
                ? new ManagementClient(_sbConnectionStringBuilder) : new ManagementClient(_sbConnectionStringBuilder, _tokenProvider);
        }
Ejemplo n.º 2
0
 public IMessageReceiver Create(string queueName)
 {
     return(_sbConnectionStringBuilder.HasSasKey()
         ? new MessageReceiver(new ServiceBusConnection(_sbConnectionStringBuilder), queueName)
         : new MessageReceiver(_sbConnectionStringBuilder.Endpoint, queueName, _tokenProvider));
 }
 private MessageSender CreateMessageSender(string queueName) => _sbConnectionStringBuilder.HasSasKey()
     ? new MessageSender(new ServiceBusConnection(_sbConnectionStringBuilder), queueName)
     : new MessageSender(_sbConnectionStringBuilder.Endpoint, queueName, _tokenProvider);