question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Event processing order

See original GitHub issue

I have a doubt about the order in which the events will be handled/reduced.

Let’s say I send a command with CreateUser. That command will then register an event UserCreated that will be reduced by a User entity.

In my application, I want to be able to access that User that has just been created (via Booster.fetchEntitySnapshot), so I create a new event AfterUserCreation that will have User as a param. This new event will be fired by the UserCreated event handler:

@EventHandler(UserCreated)
export class HandleUserCreated {
    public static async handle(
        event: UserCreated,
        register: Register
    ): Promise<void> {

       //Here is where I'd perform Booster.fetchEntitySnapshot to get User

        register.events(new AfterUserCreation(
           //Here I'd pass the User resulting from the fetch
        ))
    }
}

My main concern here is whether the event handler will be able to fetch the User entity. I mean, WHEN does the event handler comes into action? does it wait until the Userentity reduces the first UserCreated? or is it launched “in parallel”?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
NickSeagullcommented, Aug 14, 2020

In the case of the AWS provider, the event handlers are subscribed to the change stream from the event store, which is DynamoDB. This is the same case for the reducers, so in your example, you could say that they both are launched in parallel.

0reactions
javiertoledocommented, Aug 25, 2020

Oh, I see. Yes, this is a limitation that we should solve, in future versions, we should allow entities to reduce events that are not bound to them. I’ll make sure we have an issue to address that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Out of order events processing techniques
Out of order events processing techniques · Buffer based approach · Punctuation based approach · Speculation based approach · Approximation based ...
Read more >
Event Processing Order | Cribl Docs
Event Processing Order ​ · Sources: Data arrives from your choice of external providers. · Custom command: Optionally, you can pass this input's...
Read more >
Event processing order for monitors
Processes events in the order in which they arrive on the context's input queue. * Completely processes one event before it moves on...
Read more >
How I am handling out-of-order events - Level Up Coding
IOP — In Order Processing — usually using a buffer to store multiple events which we can later order before actually dispatching them...
Read more >
Idempotency and ordering in event-driven systems
Idempotency is a property of an operation that allows it to be applied multiple times without changing the result.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found