Install using nuget DS.SimpleServiceBus.RabbitMq Install RabbitMQ and use the management gui to create a new virtual host
Create an instance of BusService:
var busService = BusServiceFactory.Create.UsingRabbitMq(cfg =>
{
cfg.Uri = "rabbitmq://localhost/dsevents";
cfg.Username = "guest";
cfg.Password = "guest";
});
Start the Bus
await busService.StartAsync(CancellationToken.None);
Install using nuget DS.SimpleServiceBus.EventHubs Go to Azure portal and create a new EventHub and a storage account.
Create an instance of BusService:
var eventHubsBusService = BusServiceFactory.Create.UsingEventHubs(x =>
{
x.ConsumerGroup = "{YourConsumerGroupName}";
x.EventHubConnectionString = "{YourEventHubCS}";
x.EventHubName = "{TheNameOfYourEventHub}";
x.StorageConnectionString = "{YourStorageCS}";
x.StorageAccountName = "{YourStorageAccountName}";
});
Start the Bus
await busService.StartAsync(CancellationToken.None);
- Create a model class implementing the IModel interface
- Create an event class implementing the IEvent using your newly created model class
- Create an eventhandler implementing the IEventHandler using your newly created event class
Create an instance of EventService
var eventService = EventServiceFactory.Create.UsingRabbitMq(busService, cfg => cfg.EventQueueName = "thiseventserviceuniquequeuename");
Register your eventhandler
eventService.RegisterEventHandler<YourEventHandler>();
Publish an event
await eventService.PublishAsync(InstanceOfYourEventClass, CancellationToken.None);
- Create a class implementing the IRequestModel interface
- Create a class implementing the IResponseModel interface
- Create a commandhandler implementing the ICommandHandler<TRequestModel, TResponseModel> using your newly created classes
Create an instance of CommandService
var commandService = CommandServiceFactory.Create.UsingRabbitMq(busService, cfg => cfg.CommandQueueName = "thiscommandserviceuniquequeuename");
Register your commandhandler
commandService.RegisterCommandHandler<YourCommandHandler>();
Send a request
var response = await commandService.SendRequestAsync<YourRequestClass, YourResponseClass>(instanceOfRequestClass, CancellationToken.None);