Optimizing Event Handling in Message Validation: Challenges with onAny, on, and use in Sequential Processing #5218
Unanswered
devprog-dev
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have some questions about onAny(), on(), and use.
In my current setup, when any message comes in, I first need to determine whether the sender is a valid user. Initially, I used only on() with an if statement to identify the user. However, as the number of on events increased, I occasionally missed adding the if statement, leading to issues.
To address this, I switched to onAny, but I noticed that even with onAny, the on-registered events still fire. It turns out that onAny and on events trigger sequentially.
So, I considered using use to inspect incoming events, then calling next() to forward them to the on events. However, I feel there might be another, potentially better, approach.
One alternative I thought of was storing messages received via onAny in a queue and processing them later, but implementing this would require substantial code changes in my current project, so I'd rather avoid that.
If there’s another method I could use, I’d appreciate your guidance.
Beta Was this translation helpful? Give feedback.
All reactions