Created
July 9, 2014 12:33
-
-
Save grumpydev/25bedea62bb53a9c0beb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace AzureQueue | |
| { | |
| using System.ServiceModel.Channels; | |
| using AzureNetQ; | |
| using AzureNetQ.Loggers; | |
| using AzureNetQ.Producer; | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var connectionString = "Endpoint=sb://eventenginetest.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=/h1b/4xoKHn7K2SYojFQ8GIrh1vSwzDOAbEifx5w1WA="; | |
| var settings = new AzureNetQSettings(); | |
| settings.Logger = () => new ConsoleLogger(); | |
| var bus = AzureBusFactory.CreateBus(connectionString, settings); | |
| bus.Logger.DebugWrite("Erm"); | |
| bus.Subscribe<TestMessage>( | |
| msg => Console.WriteLine("TestTopicSub1: {0}", msg.Contents), | |
| x => | |
| { | |
| x.WithSubscription("testSubscription"); | |
| x.WithTopic("testTopic"); | |
| }); | |
| bus.Subscribe<TestMessage>( | |
| msg => Console.WriteLine("TestTopic2: {0}", msg.Contents), | |
| x => | |
| { | |
| x.WithSubscription("testSubscription2"); | |
| x.WithTopic("testTopic2"); | |
| }); | |
| bus.Publish(new TestMessage("Contents"), "testTopic"); | |
| bus.Publish(new TestMessage("Contents2"), "testTopic"); | |
| bus.Publish(new TestMessage("Contents3"), "testTopic2"); | |
| bus.Publish(new TestMessage("Contents4"), "testTopic2"); | |
| Console.ReadLine(); | |
| } | |
| } | |
| public class TestMessage | |
| { | |
| public string Contents { get; set; } | |
| public TestMessage(string contents) | |
| { | |
| this.Contents = contents; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment