Skip to content

Instantly share code, notes, and snippets.

@clemensv
Created December 10, 2012 19:33
Show Gist options
  • Save clemensv/4252776 to your computer and use it in GitHub Desktop.
Save clemensv/4252776 to your computer and use it in GitHub Desktop.
ForwardTo Minimal Sample
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