Topic Wildcards

561 views
Skip to first unread message

Tobias Oberstein

unread,
Mar 24, 2012, 6:04:57 AM3/24/12
to mq...@googlegroups.com
Are wildcards allowed in UNSUBSCRIBE messages?

Specifically, the spec talks about wildcards being

"The multi-level wildcard and single-level wildcard can be used for
subscriptions, but they cannot be used within a topic by the publisher
of a message."

I.e.

PUBLISH: not allowed
SUBSCRIBE: allowed
UNSUBSCRIBE: ??
all other msgs: not allowed

?

For example, given a client has subscribed to

finance/stock/ibm/#

and receives messages for (fully qualified) topics

finance/stock/ibm
finance/stock/ibm/closingprice
finance/stock/ibm/currentprice
...

how does the client unsubscribe?

The set of topics for a subscription using a wildcard
is open ended, since topics used for publications are not
"preregistered", right?

So even unsubscribing from the 3 qualified topics

finance/stock/ibm
finance/stock/ibm/closingprice
finance/stock/ibm/currentprice

won't suffice, since

finance/stock/ibm/dayavgprice

might still be received.

How does that work?

Thanks,

\Tobias

Nicholas O'Leary

unread,
Mar 24, 2012, 6:45:37 AM3/24/12
to mq...@googlegroups.com
Hi Tobias,

yes, wildcards may be used in UNSUBSCRIBE messages.

So a subscription to finance/stock/ibm/# is removed by unsubscribing
to exactly the same topic string - finance/stock/ibm/#

Regards,
Nick

> --
> 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

Tobias Oberstein

unread,
Mar 24, 2012, 6:55:13 AM3/24/12
to mq...@googlegroups.com, Nicholas O'Leary
Hi Nicholas,

> yes, wildcards may be used in UNSUBSCRIBE messages.
>
> So a subscription to finance/stock/ibm/# is removed by unsubscribing
> to exactly the same topic string - finance/stock/ibm/#

Just to get that right .. is the following correct?

1)
Client subscribes "finance/stock/ibm/#" and
unsubscribes "finance/stock/ibm/closingprice"

The unsubscribe for "finance/stock/ibm/closingprice" is silenty
ignored (was never subscribed on that very "topic subsc. string")

It will still receive msgs for "finance/stock/ibm/closingprice"
since it is still subscribed to "finance/stock/ibm/#"

2)
Client subscribes "finance/stock/ibm/closingprice" and
unsubscribes "finance/stock/ibm/#"

The unsubscribe for "finance/stock/ibm/#" is silenty
ignored (was never subscribed on that very "topic subsc. string")

It will still receive msgs for "finance/stock/ibm/closingprice"
since it is still subscribed to "finance/stock/ibm/closingprice"

3)
Client subsribes "finance/stock/ibm/#" and
subscribes "finance/stock/ibm/closingprice"

Client will receive msgs published to "finance/stock/ibm/closingprice"
_twice_

==

In other words, "topic subscription strings" are interpreted merely
syntactically and have no "set semantics"?
[Dont know how to express that better .. hope you get it from ctx above]

Thanks!

\Tobias

Roger Light

unread,
Mar 24, 2012, 8:44:32 AM3/24/12
to mq...@googlegroups.com
Hi Tobias,

> 1)
> Client subscribes "finance/stock/ibm/#" and
> unsubscribes "finance/stock/ibm/closingprice"
>
> The unsubscribe for "finance/stock/ibm/closingprice" is silenty
> ignored (was never subscribed on that very "topic subsc. string")
>
> It will still receive msgs for "finance/stock/ibm/closingprice"
> since it is still subscribed to  "finance/stock/ibm/#"

This is correct.

> 2)
> Client subscribes "finance/stock/ibm/closingprice" and
> unsubscribes "finance/stock/ibm/#"
>
> The unsubscribe for "finance/stock/ibm/#" is silenty
> ignored (was never subscribed on that very "topic subsc. string")
>
> It will still receive msgs for "finance/stock/ibm/closingprice"
> since it is still subscribed to "finance/stock/ibm/closingprice"

This is correct.

> 3)
> Client subsribes "finance/stock/ibm/#" and
> subscribes  "finance/stock/ibm/closingprice"
>
> Client will receive msgs published to "finance/stock/ibm/closingprice"
> _twice_

As Nick already mentioned in another email, overlapping subscriptions
should not result in a message being received more than one. This is
however an outstanding bug in mosquitto - you will receive the message
twice in the above situation.

Cheers,

Roger

Reply all
Reply to author
Forward
0 new messages