Skip to content
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

Using wildcards when publishing messages? #31

Closed
JoseTomasTocino opened this issue Apr 14, 2013 · 5 comments
Closed

Using wildcards when publishing messages? #31

JoseTomasTocino opened this issue Apr 14, 2013 · 5 comments

Comments

@JoseTomasTocino
Copy link

I know it's possible to use wildcards when referencing topic names in the suscriptions. However, it does not seem possible to use wildcards to target multiple topics when publishing messages.

Am I doing something wrong or is it simply not supported?

@dcneiner
Copy link
Contributor

@JoseTomasTocino Postal does not currently support publishing to a wildcard. The wildcards allow you to subscribe to any number of topics being published, but the topics are expected to be specific:

Subscription: model.*.data
Topic Published: model.customer.data or model.app.data would both cause the subscription to fire.

Can you explain why you were wanting to use a wildcard in the publication? It might help me or @ifandelse understand so we can point you in the right direction.

@JoseTomasTocino
Copy link
Author

@dcneiner I was writing a blog post about postal.js (you can see it here). In the example I came up with, there's a TheWeatherChannel where messages about the weather are published. The topics of the messages are, like, Rain.improves, Wind.stops, etc. I just wanted to be able to send a message saying that all weather phenomena have stopped, hence the use of *.stop when publishing.

However, reading your documentation more carefully I found out that I can replace the resolver with my own one that may accept using wildcards when publishing.

@dcneiner
Copy link
Contributor

@JoseTomasTocino I can understand why you might want to do something in your given blog post example, but I have not personally needed a wildcard publication in an actual application. But you found out how to accomplish it should you really need to!

Glad to see you writing about publishing and that you are enjoying @elijahmanor 's blog series! He is a great guy!

@ifandelse
Copy link
Contributor

@JoseTomasTocino you can certainly implement your own resolver if you want, but I'd encourage you to rethink the need to publish a wildcard. The point of this kind of messaging is to allow subscribers to indicate the specific messages in which they are interested. By allowing the publisher to dictate which subscribers receive a message - instead of simply letting the subscribers handle that on their own via their subscriptions - you are introducing a subtle but eventually-dangerous form brittle-ness into your application that can be solved in a different (and better, IMO) way. If you need to publish a message indicating that all weather phenomena have stopped, I would make that it's own message. You can still have topics like Rain.improves, Wind.stops, etc., but that doesn't preclude you from having Weather.stop. In fact, if Weather.stop and rain.stop are published on the same channel, your subscriber need only subscribe to *.stop. The key here is to try and model the real nature of what's going on: the rain stopping, and ALL weather phenomena stopping are truly two distinct events, and should get their own message. I hope that's helpful! Good luck!

@JoseTomasTocino
Copy link
Author

Thanks for your comments guys! They've been really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants