Created
December 10, 2012 19:33
-
-
Save clemensv/4252776 to your computer and use it in GitHub Desktop.
ForwardTo Minimal Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleApplication2 | |
{ | |
using System; | |
using System.Configuration; | |
using Microsoft.ServiceBus; | |
using Microsoft.ServiceBus.Messaging; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string cs = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"]; | |
NamespaceManager ns = NamespaceManager.CreateFromConnectionString(cs); | |
ns.CreateQueue(new QueueDescription("q2")); | |
ns.CreateQueue(new QueueDescription("q1") {ForwardTo = "q2"}); | |
MessagingFactory m = MessagingFactory.CreateFromConnectionString(cs); | |
QueueClient qc1 = m.CreateQueueClient("q1"); | |
qc1.Send(new BrokeredMessage {Properties = {{"Greeting", "Hello"}}}); | |
QueueClient qc2 = m.CreateQueueClient("q2"); | |
BrokeredMessage rm = qc2.Receive(); | |
Console.WriteLine(rm.Properties["Greeting"]); | |
ns.DeleteQueue("q1"); | |
ns.DeleteQueue("q2"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment