Hello, I had my first experience with your implementation of the event bus. After some experiments, I am a bit confused about the way it works. Let me try to explain the situation:
Application service do database transaction and then triggers an event:
public class OfferAppService : ApplicationService { public IEventBus EventBus { get; set; }
<br> public OfferAppService() { EventBus = NullEventBus.Instance; }
public async Task AcceptOffer(AcceptOfferInput input) { //DATABASE TRANSACTION
await EventBus.TriggerAsync(new OfferAcceptedEvent { RequestId = input.RequestId }); or EventBus.Trigger(new OfferAcceptedEvent { RequestId = input.RequestId }); } }
<br> Two handlers waits for events and do other business.
public async Task HandleEventAsync(OfferAcceptedEvent eventData)
{ //DO STUFF await Task.Delay(5000); }
public async Task HandleEventAsync(OfferAcceptedEvent eventData) { //DO STUFF await Task.Delay(10000); }
After some tests I find out what AcceptOffer methods takes 15s to finish a execution. Should it be like this? I imagined what AcceptOffer should not wait until events will be processed.
4 Answer(s)
-
0
Hi @mirzanas
ABP's implementation works like that. If you want to run non-blocking operations, you can try to use https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers
-
0
Hi @ismcagdas ,
Do you have sample project on implementation of event bus?
Thanks
-
0
There is only one implementation of Event Bus, in ABP: EventBus.cs
If you mean Event Handler, there is: UserFriendCacheSyncronizer.cs
If you mean Background Job, there is: UserCollectedDataPrepareJob.cs
If you mean how to enqueue, there is: ProfileAppService.cs#L143
-
0
Thanks @aaron for the pointers.