New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type Matching Event Bus Messages? #1902
Comments
Hi, I think it would work better if you use your own static method to do that:
used like:
In addition it allows you to come up with a richer API if needed. |
How would that work with multiple consumers for different types though? I was thinking along the lines of:
|
in your case |
Perhaps I'm not explaining it properly... It seems to me that your solution would deliver the message to all of the handlers, regardless of type; then the handler would discard non-matching items. In that case, wouldn't I have to "publish" so that multiple typed handlers could each receive the message? My thoughts on this would be that the eventbus code could have logic added so that it only tries to deliver to an appropriately typed handler. That way the "send" method could be used and the event bus would only deliver to the appropriately typed handler. |
I understand but a message is sent/published regardless to an address, regardless of the recipient. If you need such semantic I think you should use different addresses instead and use a convention to map the recipient to addresses. |
Yeah, I certainly see your point. I'll close this and think about it further... Thanks!!! |
I think it would be quite valuable to support an overloaded method for the EventBus consumer to allow specifying the type of the message:
This would allow for type-safe message handling and allow for matching different consumers to different types. I'll try to look into what it would take to make this possible. It obviously wouldn't easily apply to some of the dynamic languages though...
The text was updated successfully, but these errors were encountered: