Created
February 14, 2012 08:30
-
-
Save lanwin/1824814 to your computer and use it in GitHub Desktop.
This is an example how to use our Rabbit Service Bus.
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
/* 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