Created
December 10, 2012 20:21
-
-
Save clemensv/4253067 to your computer and use it in GitHub Desktop.
ForwardTo with Topics and Session Queues
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"]; | |
var ns = NamespaceManager.CreateFromConnectionString(cs); | |
ns.CreateQueue(new QueueDescription("q2") { RequiresSession = true }); | |
var td = ns.CreateTopic(new TopicDescription("t1")); | |
ns.CreateSubscription( new SubscriptionDescription(td.Path, "s1"){ ForwardTo = "q2"}); | |
var m = MessagingFactory.CreateFromConnectionString(cs); | |
var tc1 = m.CreateTopicClient("t1"); | |
tc1.Send(new BrokeredMessage { SessionId = "myid", Properties = { { "Greeting", "Hello" } } }); | |
var qc2 = m.CreateQueueClient("q2"); | |
var session = qc2.AcceptMessageSession(); | |
var rm = session.Receive(); | |
Console.WriteLine(rm.Properties["Greeting"]); | |
ns.DeleteTopic("t1"); | |
ns.DeleteQueue("q2"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment