Benutzer:MovGP0/Service Bus

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
   MovGP0        Über mich        Hilfen        Artikel        Weblinks        Literatur        Zitate        Notizen        Programmierung        MSCert        Physik      


using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
Send Message
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-Services benötigen eine Änderung am Binding auf ServiceBus