These are Rebus extensions for short Func map to a service class.
You can install Rebus.Extensions.ServiceMap with NuGet:
dotnet add package Rebus.Extensions.ServiceMap
// startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddRebus();
services.AddTransient<IOrdersService, OrdersService>();
// add service map
services
.AddRebusCommand<IOrdersService, CreateOrderCommand>(
(orderService, message, cancellationToken) => orderService.CreateOrderAsync(message, cancellationToken))
.AddRebusRequest<IOrdersService, UpdateOrderRequest, UpdateOrderResponse>
(orderService, message, cancellationToken) => orderService.UpdateOrderAsync(message, cancellationToken));
}
The IOrdersService should be similar to:
interface IOrdersService
{
Task CreateOrderAsync(CreateOrderCommand message, CancellationToken cancellationToken);
Task<UpdateOrderResponse> UpdateOrderAsync(UpdateOrderRequest message, CancellationToken cancellationToken);
}
// startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddRebus(
configure => configure
.AddDefaultRouting("main-queue")
...
}