public async Task <TopicDescription> CreateTopic(TopicDescription topicDescription) { var topicExists = await _namespaceManager.TopicExistsAsync(topicDescription.Path).ConfigureAwait(false); if (topicExists) { topicDescription = await _namespaceManager.GetTopicAsync(topicDescription.Path).ConfigureAwait(false); } else { try { if (_log.IsDebugEnabled) { _log.DebugFormat("Creating topic {0}", topicDescription.Path); } topicDescription = await _namespaceManager.CreateTopicAsync(topicDescription).ConfigureAwait(false); } catch (MessagingEntityAlreadyExistsException) { await _namespaceManager.GetTopicAsync(topicDescription.Path).ConfigureAwait(false); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Topic: {0} ({1})", topicDescription.Path, string.Join(", ", new[] { topicDescription.RequiresDuplicateDetection ? "dupe detect" : "" }.Where(x => !string.IsNullOrWhiteSpace(x)))); } return(topicDescription); }
public async Task <TopicDescription> CreateTopic(TopicDescription topicDescription) { var topicExists = await _namespaceManager.TopicExistsAsync(topicDescription.Path).ConfigureAwait(false); if (topicExists) { topicDescription = await _namespaceManager.GetTopicAsync(topicDescription.Path).ConfigureAwait(false); } else { try { LogContext.Debug?.Log("Creating topic {Topic}", topicDescription.Path); topicDescription = await _namespaceManager.CreateTopicAsync(topicDescription).ConfigureAwait(false); } catch (MessagingEntityAlreadyExistsException) { await _namespaceManager.GetTopicAsync(topicDescription.Path).ConfigureAwait(false); } } LogContext.Debug?.Log("Topic: {Topic} ({Attributes})", topicDescription.Path, string.Join(", ", new[] { topicDescription.RequiresDuplicateDetection ? "dupe detect" : "", topicDescription.EnablePartitioning ? "partitioned" : "", topicDescription.SupportOrdering ? "ordered" : "", }.Where(x => !string.IsNullOrWhiteSpace(x)))); return(topicDescription); }