Skip to content

Instantly share code, notes, and snippets.

@mishrsud
Created April 28, 2016 05:52
Show Gist options
  • Save mishrsud/9f2c937d83c7499cc02347b55ca6bedf to your computer and use it in GitHub Desktop.
Save mishrsud/9f2c937d83c7499cc02347b55ca6bedf to your computer and use it in GitHub Desktop.
// METHOD 1 No receive endpoint (this is meant for Publish in a pub-sub scenario)
public IBusControl CreateBusControl()
{
var bus = Bus.Factory.CreateUsingRabbitMq(configurator =>
{
IRabbitMqHost rabbitMqHost = configurator.Host(new Uri("rabbitmq://localhost/test"), hostConfigurator =>
{
hostConfigurator.Username("guest");
hostConfigurator.Password("guest");
});
});
return bus;
}
// METHOD: 2 Initializes bus on the subscriber with receive endpoint and consumer
public IBusControl CreateBusControlWithReceiveEndpointAndConsumer()
{
var bus = Bus.Factory.CreateUsingRabbitMq(configurator =>
{
IRabbitMqHost rabbitMqHost = configurator.Host(new Uri("rabbitmq://localhost/test"), hostConfigurator =>
{
hostConfigurator.Username("guest");
hostConfigurator.Password("guest");
});
configurator.ReceiveEndpoint(rabbitMqHost, "myReceiveQueue", e => e.Consumer<SomeConsumer>());
});
return bus;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment