Skip to content

Instantly share code, notes, and snippets.

@lanwin
Created February 14, 2012 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanwin/1824814 to your computer and use it in GitHub Desktop.
Save lanwin/1824814 to your computer and use it in GitHub Desktop.
This is an example how to use our Rabbit Service Bus.
/* Initialize bus. In this case via Autofac */
builder.RegisterModule(new RabbitModule
{
HostName = "localhost",
UserName = "user",
Password = string.Empty,
Exchanges = {
new Exchange("exchange1"){Durable=true;},
new Exchange("exchange2"){Durable=true;}
}
});
/* Then in each feature you declare what you want to consume */
_disposeable = _bus.Consume(new MessageQueue()
{
Name = "foobar" /* leave empty for private queue */,
Purge = true,
Scheduler = MessageSchedulers.ThreadPerCpu,
DequeueCount = 100,
Bindings = new[]
{
new Exchange("barfoo"){Durable=true}, // directly binds exchange to foobar after
}
});
/*
There are also properties like Invoker which is set per default to AutofacInvoker which resolves a IMessageHandler for each message.
Later i plan to add somthing like
ErrorAction = ErrorActions.RetryAndForwardAfter(10,"forwared_error_queue")
*/
/* This consum is reestablished if the connection gets lost and reconnectes after 10sec */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment