Skip to content

Instantly share code, notes, and snippets.

@grumpydev
Created July 9, 2014 12:33
Show Gist options
  • Save grumpydev/25bedea62bb53a9c0beb to your computer and use it in GitHub Desktop.
Save grumpydev/25bedea62bb53a9c0beb to your computer and use it in GitHub Desktop.
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