Created
October 16, 2012 07:36
-
-
Save wattsm/3897822 to your computer and use it in GitHub Desktop.
Example message consumer factory
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
public class ExampleConsumerFactory : ConsumerFactoryBase { | |
public override IEnumerable<IMessageConsumer> GetConsumers(IMessageContext messageContext) { | |
var consumers = new List<IMessageConsumer>(); | |
if(messageContext.Message.Headers.Exists("queues")) { | |
var queues = messageContext | |
.Message | |
.Headers | |
.GetValue("queues") | |
.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); | |
foreach(var queue in queues) { | |
var path = String.Format(".\private$\{0}", queue); | |
var consumer = new MsmqMessageConsumer(); | |
consumer.Configure(new Dictionary<string, string> { { "queue-path", path } }); | |
consumers.Add(consumer); | |
} | |
} | |
return consumers; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment