Why can't use wildcard in PUBLISH ?

1,629 views
Skip to first unread message

xu zhangxuan

unread,
Oct 21, 2012, 11:40:25 PM10/21/12
to mq...@googlegroups.com
Hi all:

In my case, I want do something as following:

subs:
 client-1: A/B/C/D
 client-2: A/2/C/D
 client-3: A/B/3/D

first, I want push message to all clients subscribed to A/B (client-2 and client-3 in this case)
So I want to use A/B/+/+ as publish topic.

and then, I want push message to all clients subscribed to A/C (client-1 and client-2 in this case)
So I want to use A/+/C/+ as publish topic.

But using wildcard in publish message is not allowed. Any suggestions ?
---
Regards.

Zhangxuan Xu
plu...@gmail.com


Roger Light

unread,
Oct 22, 2012, 4:46:16 AM10/22/12
to mq...@googlegroups.com
Hi Xu,

The simple answer is that it doesn't work like that. None of your
clients are subscribed to A/B or A/C.

What you suggest sounds like a reasonable idea, so the question is why
it doesn't it work like that? In the current model, subscribers decide
what topics they listen to. The power to decide that lies with them
alone. In your scenario, the publisher now also controls what topics
subscribers are listening to, which is an important change and not
desirable from the subscriber point of view.

In your example, I would have subscriptions as follows:

client-1: A/C
client-2: A/B and A/C
client-3: A/B

I realise that you have only described a trivial example though.

Cheers,

Roger

xu zhangxuan

unread,
Oct 22, 2012, 5:35:19 AM10/22/12
to mq...@googlegroups.com
Hi Roger:

Thanks for your interpretation. As you say, In MQTT subscribers decide what topics they listen to.
But what I want is publisher decide who would receive the message. So it's totally different. Maybe I 
need make my own message breaker's subscribe-rule different from which defined in MQTT.
---
Regards.

Zhangxuan Xu
plu...@gmail.com


--
--
To learn more about MQTT please visit http://mqtt.org

To post to this group, send email to mq...@googlegroups.com
To unsubscribe from this group, send email to
mqtt+uns...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/mqtt




Roger Light

unread,
Oct 22, 2012, 5:58:21 AM10/22/12
to mq...@googlegroups.com
Hi Xu,

> But what I want is publisher decide who would receive the message. So it's
> totally different.

The principle isn't completely different, but I think you're
approaching it from the opposite direction. You seem to be thinking
along the lines of "as a publisher, how do I force clients to receive
this message?". MQTT takes the view if a subscriber wants information,
they will subscribe to the topics that will provide it for them and
the publisher will publish to that topic. If you don't trust your
subscribers to subscribe to the correct topics, you can't assume that
they will process your message anyway. If you do trust your clients to
subscribe to the correct topics, then there is no need to force
messages upon them.

Cheers,

Roger
Reply all
Reply to author
Forward
0 new messages