Benutzer:MovGP0/Service Bus
Zur Navigation springen
Zur Suche springen
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
Service Bus[Bearbeiten | Quelltext bearbeiten]using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
Topics[Bearbeiten | Quelltext bearbeiten]
string topicName = "Orders";
var tokenProvider = SharedSecretTokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerKey);
var namespacemanager = new NamespaceManager(myServiceBusNamespaceUri, tokenProvider);
if(!namespacemanager.TopicExists(topicName))
{
var topicDescription = namespacemanager.CreateTopic(topicName);
namespacemanager.CreateSubscription(topicDescription.Path, "StandardOrder", new SqlFilter("Total < 1000"));
namespacemanager.CreateSubscription(topicDescription.Path, "PriorityOrder", new SqlFilter("Total >= 1000"));
}
var standardMessage = new BrokeredMessage("Some standard order");
standardMessage.Properties["Total"] = 100;
var priorityMessage = new BrokeredMessage("Some priority order");
priorityMessage.Properties["Total"] = 2000; // custom property
priorityMessage.TimeToLive = TimeSpan.FromSeconds(10); // default property
var messagingFactory = MessagingFactory.Create(myServiceBusNamespaceUri, tokenProvider);
var topicClient = messagingFactory.CreateTopicClient(topicName);
topicClient.Send(standardMessage);
topicClient.Send(priorityMessage);
topicClient.Close();
WCF[Bearbeiten | Quelltext bearbeiten]
Weblinks[Bearbeiten | Quelltext bearbeiten]
|