private Binding TryBinding(string topic, Type type, object message) { try { _topicManagement.CreateTopicIfMissing(topic, message.GetType()); return(new Binding(_settings, _topicManagement, topic, type, _logger)); } catch (Exception e) { _logger.LogError(e, "{method}: Calling recovery on topic '{topic}' for new Binding. Cause: error occurred {e}", nameof(TryBinding), topic, e); return(null); } }
internal Binding( AzureBusTopicSettings settings, AzureBusTopicManagement queueManagement, string topic, Type type, ILogger <AzureTopicPublisher> logger) { _logger = logger; _settings = settings; _topic = topic; _excludeTopicsFromLogging = new LoggingConfiguration().ExcludeTopicsFromLogging(); queueManagement.CreateTopicIfMissing(_topic, type); var retryPolicy = new RetryExponential( TimeSpan.FromSeconds(settings.AzureRetryMinimumBackoff), TimeSpan.FromSeconds(settings.AzureRetryMaximumBackoff), settings.AzureMaximumRetryCount ); _topicClient = new TopicClient(settings.ConnectionString, _topic, retryPolicy); _logger.LogInformation("Created new MQ binding '{topic}'.", _topic); }