https://github.com/cheolwo/FullFillmentService/tree/main/FullFillMentSoulution/OrderServer

FullFillmentService/FullFillMentSoulution/OrderServer at main · cheolwo/FullFillmentServiceFullFillmentService. Contribute to cheolwo/FullFillmentService development by creating an account on GitHub.github.com


CQRS 라는 개발패턴으로 만들어봤어.

Front는 Blazor

BackEnd는 Asp.net Core Web API.





Front 이용 라이브러리

Back 이용 라이브러리


전체 프로젝트




도면에서 보이듯 충돌날까봐 EventQue는 Lock걸어서 접근해.


public Task EnqueueEventAsync(IEvent @event)

{
lock (_lock)
{
_eventQueue.Enqueue(@event);
if (@event is CreateOrderCommand createOrderCommand)
{
Console.WriteLine(createOrderCommand.Name);
}
}

return Task.CompletedTask;
}

public Task<IEvent> DequeueEventAsync()
{
lock (_lock)
{
if (_eventQueue.Count > 0)
{
return Task.FromResult(_eventQueue.Dequeue());
}
}

return Task.FromResult<IEvent>(null);
}

public async Task ProcessEventsAsync()
{
while (true)
{
IEvent @event;
lock (_lock)
{
if (_eventQueue.Count == 0)
{
break; // No events to process, exit the loop
}

@event = _eventQueue.Dequeue();
}

await ProcessEventAsync(@event);
}
}

EFCore 와 잘 연동되는 모습



My SQL 결과물