本文整理汇总了C#中TopicDescription类的典型用法代码示例。如果您正苦于以下问题:C# TopicDescription类的具体用法?C# TopicDescription怎么用?C# TopicDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TopicDescription类属于命名空间,在下文中一共展示了TopicDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TopicShouldExistAsync
private async static Task TopicShouldExistAsync(NamespaceManager ns, TopicDescription topicDescription)
{
if (!await ns.TopicExistsAsync(topicDescription.Path))
{
throw new MessagingEntityNotFoundException("Topic: " + topicDescription.Path);
}
}
示例2: Main
static void Main(string[] args)
{
NamespaceManager manager = NamespaceManager.Create(); // Automatycznie bierze informacje z App.config
//Wolę na początku - wygodniej "zaczynamy" zawsze od zera
manager.DeleteTopic("obliczenia"); //Kasuje temat i subskrypcje
manager.DeleteQueue("wynik");
//Tworzenie Topics - tematu
TopicDescription td = new TopicDescription("obliczenia");
//Nie przewidujemy dużego ruchu nie wymagamy partycjonowania
td.EnablePartitioning = false;
//Wymagamy wykrywania duplikatów - by klient 2 razy nie wysłał tego samego polecenia
td.RequiresDuplicateDetection = true;
//Nie pozwalamy na tematy tylko w pamięci; chcemy żeby klient był pewien że wysłał wiadomość = wiadomość zostanie przetworzona
td.EnableExpress = false;
manager.CreateTopic(td); //Tworzenie tematu
//Suma i średnia będzie wyliczana gdy opowiednia własciwość zostanie zdefiniowana
manager.CreateSubscription("obliczenia", "suma", new SqlFilter("suma=1"));
manager.CreateSubscription("obliczenia", "srednia", new SqlFilter("srednia=1"));
//Ale zawsze będą liczone elementy w komunikacie
manager.CreateSubscription("obliczenia", "liczba");
QueueDescription qd = new QueueDescription("wynik");
qd.RequiresSession = true;
manager.CreateQueue(qd);
}
示例3: Equals
public bool Equals(TopicDescription other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;
return Equals(other.Path, Path);
}
示例4: EnsureTopicAsync
public async static Task<TopicClient> EnsureTopicAsync(this MessagingFactory factory, TopicDescription topicDescription)
{
await new NamespaceManager(factory.Address, factory.GetSettings().TokenProvider)
.TryCreateEntity(
mgr => TopicCreateAsync(mgr, topicDescription),
mgr => TopicShouldExistAsync(mgr, topicDescription));
return factory.CreateTopicClient(topicDescription.Path);
}
示例5: TopicCreateAsync
private async static Task TopicCreateAsync(NamespaceManager ns, TopicDescription topicDescription)
{
if (!await ns.TopicExistsAsync(topicDescription.Path))
{
await ns.CreateTopicAsync(topicDescription);
ServiceBusEventSource.Log.CreatedTopic(ns.Address.ToString(), topicDescription.Path);
}
}
示例6: GetTopicSubscription
public static TopicSubscriptionSettings GetTopicSubscription(this IMessageNameFormatter messageNameFormatter, Type messageType)
{
bool temporary = IsTemporaryMessageType(messageType);
var topicDescription = new TopicDescription(messageNameFormatter.GetMessageName(messageType).ToString());
var binding = new TopicSubscription(topicDescription);
return binding;
}
示例7: EventTopicPublisher
public EventTopicPublisher(string connectionString, TopicDescription topic, ITimeProvider timeProvider, ILogger logger)
{
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.TopicExists(topic.Path))
namespaceManager.CreateTopic(topic);
_client = TopicClient.CreateFromConnectionString(connectionString, topic.Path);
_timeProvider = timeProvider;
_logger = logger;
}
示例8: CreateTopicSafeAsync
public static async Task<TopicDescription> CreateTopicSafeAsync(this NamespaceManager namespaceManager, TopicDescription topicDescription)
{
bool create = true;
try
{
topicDescription = await namespaceManager.GetTopicAsync(topicDescription.Path);
create = false;
}
catch (MessagingEntityNotFoundException)
{
}
if (create)
{
bool created = false;
try
{
if (_log.IsDebugEnabled)
_log.DebugFormat("Creating topic {0}", topicDescription.Path);
topicDescription = await namespaceManager.CreateTopicAsync(topicDescription);
created = true;
}
catch (MessagingEntityAlreadyExistsException)
{
}
catch (MessagingException mex)
{
if (mex.Message.Contains("(409)"))
{
}
else
throw;
}
if (!created)
topicDescription = await namespaceManager.GetTopicAsync(topicDescription.Path);
}
if (_log.IsDebugEnabled)
{
_log.DebugFormat("Topic: {0} ({1})", topicDescription.Path,
string.Join(", ", new[]
{
topicDescription.EnableExpress ? "express" : "",
topicDescription.RequiresDuplicateDetection ? "dupe detect" : "",
}.Where(x => !string.IsNullOrWhiteSpace(x))));
}
return topicDescription;
}
示例9: CreateTopicIfDoesntExist
public TopicClient CreateTopicIfDoesntExist(string topicName, long sizeInMb, TimeSpan timeToLive)
{
if (_namespaceManager.TopicExists(topicName) == false)
{
var qd = new TopicDescription(topicName)
{
MaxSizeInMegabytes = sizeInMb,
DefaultMessageTimeToLive = timeToLive
};
_namespaceManager.CreateTopic(qd);
}
return _messagingFactory.CreateTopicClient(topicName);
}
示例10: CreateTopicIfDoesntExistSilent
public void CreateTopicIfDoesntExistSilent(string topicName, long sizeInMb, TimeSpan timeToLive)
{
if (!_namespaceManager.TopicExists(topicName))
{
var availabilityQd = new TopicDescription(topicName)
{
MaxSizeInMegabytes = sizeInMb,
DefaultMessageTimeToLive = timeToLive
};
_namespaceManager.CreateTopic(availabilityQd);
}
}
示例11: RunAsync
/// <summary>
/// Run Async
/// </summary>
/// <returns>Task</returns>
public override async Task RunAsync()
{
var exists = await this.manager.TopicExistsAsync(name);
if (!exists)
{
var td = new TopicDescription(name)
{
EnableExpress = true,
};
await this.manager.CreateTopicAsync(td);
}
}
示例12: CreateTopicClient
/// <summary>
/// Creates a topic client, as well as the target topic if it does not already exist.
/// </summary>
public static TopicClient CreateTopicClient(
this ServiceBusSettings settings,
string topicName,
Action<TopicDescription> configure = null)
{
topicName = topicName.PrefixedIfConfigured(settings);
var topicDescription = new TopicDescription(topicName);
if (configure != null)
{
configure(topicDescription);
}
settings.CreateTopicIfDoesNotAlreadyExist(topicDescription);
return TopicClient.CreateFromConnectionString(settings.ConnectionString, topicName);
}
示例13: Init
public static void Init(IEnumerable<string> nodes, ref List<QueueClient> queueClients, out TopicClient topicClient, out QueueClient frontendClient)
{
// Node Events Queues
foreach (var connectionString in nodes.Select(CloudConfigurationManager.GetSetting))
{
if (string.IsNullOrWhiteSpace(connectionString))
{
throw new NotImplementedException("Connection String can not be blank");
}
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.QueueExists(ServiceBusPathNames.ServiceBusEventQueue))
{
namespaceManager.CreateQueue(ServiceBusPathNames.ServiceBusEventQueue);
}
queueClients.Add(QueueClient.CreateFromConnectionString(connectionString, ServiceBusPathNames.ServiceBusEventQueue));
}
var workerConn = CloudConfigurationManager.GetSetting(ServiceBusConnectionStrings.WorkerServiceBusConnection);
var workerNamespace = NamespaceManager.CreateFromConnectionString(workerConn);
if (string.IsNullOrWhiteSpace(workerConn))
{
throw new NotImplementedException("Connection String can not be blank");
}
// Update Node Topic
if (!workerNamespace.TopicExists(ServiceBusPathNames.ServiceBusUpdateTopic))
{
var td = new TopicDescription(ServiceBusPathNames.ServiceBusUpdateTopic)
{
DefaultMessageTimeToLive = new TimeSpan(0, 1, 0) // TTL 1 minute
};
workerNamespace.CreateTopic(td);
}
topicClient = TopicClient.CreateFromConnectionString(workerConn, ServiceBusPathNames.ServiceBusUpdateTopic);
// Frontend Notification Queue
var nm = NamespaceManager.CreateFromConnectionString(workerConn);
if (!nm.QueueExists(ServiceBusPathNames.ServiceBusUpdateQueue))
{
nm.CreateQueue(ServiceBusPathNames.ServiceBusUpdateQueue);
}
frontendClient = QueueClient.CreateFromConnectionString(workerConn, ServiceBusPathNames.ServiceBusUpdateQueue);
}
示例14: CreateTopc
public void CreateTopc()
{
var topicDesc = new TopicDescription(TopicName)
{
MaxSizeInMegabytes = 5120,
DefaultMessageTimeToLive = new TimeSpan(0, 20, 0)
};
var namespaceManager = NamespaceManager.CreateFromConnectionString(ConnectionString);
if (!namespaceManager.TopicExists(TopicName))
{
namespaceManager.CreateTopic(topicDesc);
}
}
示例15: AzureServiceBusEndpointAddress
AzureServiceBusEndpointAddress([NotNull] Data data,
AddressType addressType)
{
if (data == null)
throw new ArgumentNullException("data");
_data = data;
_tp = TokenProvider.CreateSharedSecretTokenProvider(_data.UsernameIssuer,
_data.PasswordSharedSecret);
Uri sbUri = ServiceBusEnvironment.CreateServiceUri("sb", _data.Namespace, string.Empty);
var mfs = new MessagingFactorySettings
{
TokenProvider = _tp,
NetMessagingTransportSettings =
{
// todo: configuration setting
BatchFlushInterval = 50.Milliseconds()
},
OperationTimeout = 3.Seconds()
};
_mff = () => MessagingFactory.Create(sbUri, mfs);
_nm = new NamespaceManager(sbUri, _tp);
string suffix = "";
if (addressType == AddressType.Queue)
_queueDescription = new QueueDescriptionImpl(data.QueueOrTopicName);
else
{
_topicDescription = new TopicDescriptionImpl(data.QueueOrTopicName);
suffix = "?topic=true";
}
_rebuiltUri = new Uri(string.Format("azure-sb://{0}:{1}@{2}/{3}{4}",
data.UsernameIssuer,
data.PasswordSharedSecret,
data.Namespace,
data.QueueOrTopicName,
suffix));
_friendlyUri = new Uri(string.Format("azure-sb://{0}/{1}{2}",
data.Namespace,
data.QueueOrTopicName,
suffix));
}