feat: explicit queue client, resolve handler avoiding type registry

This commit is contained in:
2024-03-11 22:51:23 +07:00
parent 1acb74f74f
commit ae1175cf51
10 changed files with 110 additions and 31 deletions

View File

@@ -3,6 +3,7 @@ using InServiceQue.Core.Models;
using InServiceQue.Core.Repositories;
using InServiceQue.InMemory;
using InServiceQue.Sample;
using InServiceQue.Services;
using Microsoft.AspNetCore.Mvc;
var builder = WebApplication.CreateBuilder(args);
@@ -15,12 +16,12 @@ var app = builder.Build();
app.MapGet("/", async (string msg) =>
{
var taskRepository = app.Services.GetService<ITaskRepository>();
await taskRepository.InsertAsync(new QueueTask(new SendMessageTask(new SendMessagePayload()
var taskRepository = app.Services.GetService<IQueueClient>();
await taskRepository.AddTaskAsync(new QueueTask(new SendMessageTask(new SendMessagePayload()
{
From = "John", To = "Esther", Message = msg
})));
await taskRepository.InsertAsync(new QueueTask(new OtherMessageTask(msg)));
await taskRepository.AddTaskAsync(new QueueTask(new OtherMessageTask(msg)));
return new OkResult();
});