Skip to content
/ apoyos Public

Set of open source libraries for .NET Core 3+

Notifications You must be signed in to change notification settings

dealloc/apoyos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apoyos

How to use the servicebus

Add the following packages to your csproj:

<PackageReference Include="Apoyos.Servicebus" Version="1.0.0-rc" />
<PackageReference Include="Apoyos.Servicebus.RabbitMQ" Version="1.0.0-rc" />

Add the servicebus to your container:

services.AddRabbitMQ(Configuration.GetSection("Servicebus"));

For all events you want to publish, add:

services.AddDomainEvent<MyDomainEvent>("my-domain-event");

And for all event handlers you want to listen for events, add:

services.AddDomainEventListener<MyDomainEvent, MyDomainEventHandler>("my-domain-event");

Your configuration should look something like this:

{
  "Servicebus": {
    "ServiceName": "MyApplicationName",
    "RabbitMQ": {
      "Hostname": "RabbitMQHostname",
      "Username": "guest",
      "Password": "guest"
    }
  }
}

Using a custom serializer

By default Apoyos uses the JsonDomainEventSerializer in the Apoyos.Servicebus package.

Simply implement the IDomainEventSerializer interface and register it in the container after AddRabbitMQ.