internal Binding(AzureBusQueueSettings settings, ILogger <AzureQueueSubscriber> logging, AzureBusQueueManagement queueManagement) { var queueName = settings.QueueNameBuilderForSubscriber(typeof(T)); queueManagement.CreateQueIfMissing(queueName, typeof(T)); var queueClient = new QueueClient(settings.ConnectionString, queueName); _excludeQueuesFromLogging = new LoggingConfiguration().ExcludeQueuesFromLogging(); queueClient.RegisterMessageHandler( async(message, _) => { try { var body = Encoding.UTF8.GetString(message.Body); if (!_excludeQueuesFromLogging.Contains(queueName)) { logging.LogInformation("Received '{queue}': {body}", queueName, body); } var asObject = AsObject(body); Subject.OnNext(asObject); } catch (Exception ex) { logging.LogError("Message '{queue}': {message} -> consumer error: {ex}", queueName, message, ex); } }, new MessageHandlerOptions(async e => { logging.LogError("At route '{queue}' error occurred: {exception}", queueName, e.Exception); })); }
internal Binding( AzureBusQueueSettings settings, AzureBusQueueManagement queueManagement, string queue, Type type, ILogger <AzureQueuePublisher> logger) { _queue = queue; queueManagement.CreateQueIfMissing(_queue, type); _queueClient = new QueueClient(settings.ConnectionString, _queue); _excludeQueuesFromLogging = new LoggingConfiguration().ExcludeQueuesFromLogging(); logger.LogInformation("Created new MQ binding '{queue}'.", _queue); _logger = logger; }
public AzureQueueSubscriber(IOptions <AzureBusQueueSettings> settings, AzureBusQueueManagement queueManagement, ILogger <AzureQueueSubscriber> logging) { _settings = settings.Value; _queueManagement = queueManagement; _logging = logging; }
public AzureBusQueueManagement(IOptions <AzureBusQueueSettings> settings) { _settings = settings.Value; }