Awesome Open Source
Awesome Open Source

EasyBus

Lightweight Message Bus for .Net Easy integration with multiple messaging frameworks including RabbitMQ, ActiveMQ ,maybe MSMQ

Build status

EasyBus Logo

Easy to install

EasyBus.RabbitMQIntegration is on NuGet. To install it, run the following command in the Package Manager Console

Install-Package EasyBus.RabbitMQIntegration

Initialize IocBootstrapper

Container container = new Container();

//auto search all message handlers and register
container.RegisterSingle<ISubscriber>(new Subscriber(container));

var assembly = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.Contains("EasyBus.Consumer")).FirstOrDefault();

var handlers = assembly.GetExportedTypes().Where(x => x.IsMessageHandler(typeof(MessageHandler<>))).ToList();

var responders = assembly.GetExportedTypes().Where(x => x.IsMessageHandler(typeof(MessageResponder<,>))).ToList();

container.RegisterAll<IMessageHandler>(handlers);
container.RegisterAll<IResponse>(responders);
container.RegisterSingle<IPublisher>(new Publisher(container));
container.RegisterSingle(new MessageEmitter(container));
container.RegisterSingle(new RabbitMQIntegrationModule(container));

How to use?

Naming Convention for error strategy ......

<!--Number of multi-thread subscriber-->
<add key="MaxThreads" value="10" />

Pub / Sub Sample

// Find subsriber. (RabbitMQ, ActiveMQ etc.)
var subscriber = container.GetInstance<ISubscriber>();

// Find all message handlers in running process
var messageHandlers = container.GetAllInstances<IMessageHandler>();

console.WriteLine(messageHandlers.Count() + " subscriber found.", ConsoleColor.Green);

//Start to subscribe (async) for all message handlers
foreach (var item in messageHandlers)
{                    
		subscriber.Subscribe(item);
	
}


EasyBus Consumer

Specify how the policy should handle consumer faults

<add key="RetryInterval" value="1" />
<add key="RetryCount" value="3" />
 
Policy.Execute<OperationResult>(() =>
{
	
}, message);


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c-sharp (11,773
rabbitmq (243
activemq (31
service-bus (16

Find Open Source By Browsing 7,000 Topics Across 59 Categories