Hello, I'm currently working with local events in my project but I have faced 2 issues.
First one, even I set the onUnitOfWorkComplete parameter as false still the task is waiting for to complete unit of work task. My only solution is removing "await" on publichAsync. Detail is as below.
Working:
LocalEventBus.PublishAsync(
new ImportXmlEvent
{
IncomingFileId = input.IncomingModelFileId,
SourceName = input.SourceName,
ModelId = id,
CorrelationId = HttpContextAccessor.HttpContext?.TraceIdentifier
},false);
Doesn't Work:
await LocalEventBus.PublishAsync(
new ImportXmlEvent
{
IncomingFileId = input.IncomingModelFileId,
SourceName = input.SourceName,
ModelId = id,
CorrelationId = HttpContextAccessor.HttpContext?.TraceIdentifier
},false);`
Second issue, after event published, even event handler method is virtual still it is not working correctly without using _unitOfWorkManager as below. Without using _unitOfWorkManager, child entities is not commiting to the db.
Working:
[UnitOfWork]
public virtual async Task HandleEventAsync(ImportXmlEvent eventData)
{
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
{
...
}
}