Skip to content

mithosk/AgileServiceBus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

... how to create a MICROSERVICE message listener ...

[BusNamespace(Directory = "John", Subdirectory = "Doe")]
public class MyEvent
{
    public string Cat { get; set; }
    public DateTime Dog { get; set; }
    public Guid Tiger { get; set; }
}
public class MyEventHandler : IEventHandler<MyEvent>
{
    public IMicroserviceBus Bus { get; set; }
    public ITraceScope TraceScope { get; set; }

    public async Task HandleAsync(MyEvent message)
    {

    }
}
IMicroserviceLifetime ml = new RabbitMQDriver("Host=x;VHost=y;Port=z;User=k;Password=w;AppId=m");
ml.Subscribe<MyEventHandler, MyEvent>(null, null, null, null);

... how to create a MICROSERVICE rpc responder ...

[BusNamespace(Directory = "John", Subdirectory = "Doe")]
public class MyRequest
{
    public int Lion { get; set; }
    public DateTime Crocodile { get; set; }
    public Guid Horse { get; set; }
}
public class MyRequestResponder : IResponder<MyRequest>
{
    public IMicroserviceBus Bus { get; set; }
    public ITraceScope TraceScope { get; set; }

    public async Task<object> RespondAsync(MyRequest message)
    {

    }
}
ml.Subscribe<MyRequestResponder, MyRequest>(null);
ml.Startup();

... how to make a GATEWAY rpc request ...

IGatewayBus gbus = new RabbitMQDriver("Host=x;VHost=y;Port=z;User=k;Password=w;AppId=g");
MyResponse response = await gbus.RequestAsync<MyResponse>(new MyRequest
{ 
    Lion = 5, 
    Crocodile = DateTime.UtcNow,
    Horse = Guid.NewGuid()
});

... how to create a message SCHEDULER ...

ISchedulerBus sbus = new RabbitMQDriver("Host=x;VHost=y;Port=z;User=k;Password=w;AppId=s");
sbus.Schedule("* * * * *", () =>
{

    return message;
},
async (Exception e) =>
{

});