Where are retained topics stored?

568 views
Skip to first unread message

Sy

unread,
Feb 6, 2012, 11:16:13 AM2/6/12
to MQ Telemetry Transport
I am trying to trace a problem with our set-up, We have an old topic
that has been set-up with the wrong topic name, i.e.

CC/S1001/leakStatus

Where CC is a 2 letter abreviation representing the company code.
S1001 reperesents the site Identifier.

The problem is that this site has been set-up with the wrong company
code. I have created a replacement topic and this is now present in
the broker, the problem is so is the original.

Is there any way I can remove this topic so that isn't returned?

Nicholas O'Leary

unread,
Feb 6, 2012, 11:36:34 AM2/6/12
to mq...@googlegroups.com
Hi Sy,

it depends on which broker implementation you are using.

With RSMB (and I think mosquitto, but Roger would have to confirm),
you publish a message with an empty payload and the retained flag set.
This clears any previously retained message on that topic.

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

Sy

unread,
Feb 6, 2012, 12:39:02 PM2/6/12
to MQ Telemetry Transport
Thank you, I believe we are using the Java Microbroker.

On Feb 6, 4:36 pm, "Nicholas O'Leary" <nick.ole...@gmail.com> wrote:
> Hi Sy,
>
> it depends on which broker implementation you are using.
>
> With RSMB (and I think mosquitto, but Roger would have to confirm),
> you publish a message with an empty payload and the retained flag set.
> This clears any previously retained message on that topic.
>
> Regards,
> Nick
>
> On 6 February 2012 16:16, Sy <simonaplat...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I am trying to trace a problem with our set-up, We have an old topic
> > that has been set-up with the wrong topic name, i.e.
>
> > CC/S1001/leakStatus
>
> > Where CC is a 2 letter abreviation representing the company code.
> > S1001 reperesents the site Identifier.
>
> > The problem is that this site has been set-up with the wrong company
> > code.  I have created a replacement topic and this is now present in
> > the broker, the problem is so is the original.
>
> > Is there any way I can remove this topic so that isn't returned?
>
> > --
> > To learn more about MQTT please visithttp://mqtt.org

Roger Light

unread,
Feb 6, 2012, 1:11:12 PM2/6/12
to mq...@googlegroups.com
Hi,

> With RSMB (and I think mosquitto, but Roger would have to confirm),
> you publish a message with an empty payload and the retained flag set.
> This clears any previously retained message on that topic.

This is the case in mosquitto.

Cheers,

Roger

Sy

unread,
Feb 6, 2012, 1:29:41 PM2/6/12
to MQ Telemetry Transport
Thank you, I can confirm this worked a charm! Is this feature in the
specification?

Thanks again,
Simon

Nicholas O'Leary

unread,
Feb 6, 2012, 1:41:56 PM2/6/12
to mq...@googlegroups.com
Hi Sy,

glad to hear it works - means it is unlikely you are using MicroBroker
as that doesn't support this method of clearing retained messages. You
have to use its administration client to clear retained messages
out-of-band of your messaging.

When it became clear we needed a standard in-protocol way of clearing
them, we added the statement:
"A server may delete a retained message if it receives a message with
a zero-length payload and the Retain flag set on the same topic."

Note the "may" - it isn't currently a required feature of brokers.

Cheers,
Nick

Sy

unread,
Feb 6, 2012, 1:48:32 PM2/6/12
to MQ Telemetry Transport
I'm pretty sure it is the Microbroker...hang on, will sign onto box
and check...

Certainly looks like it, the installation is in a folder called
"microbroker". The jar files are:

BrokerMonitor.jar and wmqtt.jar

Start-up script contains:
/usr/java/jdk1.6.0_07/bin/java -cp jars/micro.jar:jars/micro-
mgr.jar:jars/micro-log.jar:jars/micro-registry.jar:jars/micro-
trace.jar:jars/wmqtt.jar com.ibm.micro.management.Manager -start -
name=Microbroker

I used the wmqttSample.jar to publish empty topics with the retain
flag set.

Hope that helps,


On Feb 6, 6:41 pm, "Nicholas O'Leary" <nick.ole...@gmail.com> wrote:
> Hi Sy,
>
> glad to hear it works - means it is unlikely you are using MicroBroker
> as that doesn't support this method of clearing retained messages. You
> have to use its administration client to clear retained messages
> out-of-band of your messaging.
>
> When it became clear we needed a standard in-protocol way of clearing
> them, we added the statement:
> "A server may delete a retained message if it receives a message with
> a zero-length payload and the Retain flag set on the same topic."
>
> Note the "may" - it isn't currently a required feature of brokers.
>
> Cheers,
> Nick
>
> On 6 February 2012 18:29, Sy <simonaplat...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Thank you, I can confirm this worked a charm!  Is this feature in the
> > specification?
>
> > Thanks again,
> > Simon
>
> > On Feb 6, 6:11 pm, Roger Light <ro...@atchoo.org> wrote:
> >> Hi,
>
> >> > With RSMB (and I think mosquitto, but Roger would have to confirm),
> >> > you publish a message with an empty payload and the retained flag set.
> >> > This clears any previously retained message on that topic.
>
> >> This is the case in mosquitto.
>
> >> Cheers,
>
> >> Roger
>
> > --
> > To learn more about MQTT please visithttp://mqtt.org

Nicholas O'Leary

unread,
Feb 6, 2012, 1:52:44 PM2/6/12
to mq...@googlegroups.com
Interesting.

> jars/micro.jar:jars/micro-
> mgr.jar:jars/micro-log.jar:jars/micro-registry.jar:jars/micro-
> trace.jar:jars/wmqtt.jar com.ibm.micro.management.Manager -start -
> name=Microbroker

I don't recognise any of those jar files as being what MicroBroker
supplies, nor is com.ibm.micro.management.Manager a class I know of..
but that could easily be a bit of bespoke code someone's written to
startup the broker and the jar files could have been repackaged.

The com.ibm.micro bit _is_ the main MB package, so it is likely you
have got a microbroker under the covers there somewhere.

Curious.

N

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

Sy

unread,
Feb 6, 2012, 1:55:08 PM2/6/12
to MQ Telemetry Transport
Its all before my time at the company. I think Andy Stanford set-up
the broker himself, several years ago.

On Feb 6, 6:52 pm, "Nicholas O'Leary" <nick.ole...@gmail.com> wrote:
> Interesting.
>
> > jars/micro.jar:jars/micro-
> > mgr.jar:jars/micro-log.jar:jars/micro-registry.jar:jars/micro-
> > trace.jar:jars/wmqtt.jar com.ibm.micro.management.Manager -start -
> > name=Microbroker
>
> I don't recognise any of those jar files as being what MicroBroker
> supplies, nor is com.ibm.micro.management.Manager a class I know of..
> but that could easily be a bit of bespoke code someone's written to
> startup the broker and the jar files could have been repackaged.
>
> The com.ibm.micro bit _is_ the main MB package, so it is likely you
> have got a microbroker under the covers there somewhere.
>
> Curious.
>
> N
>

Nicholas O'Leary

unread,
Feb 6, 2012, 1:58:21 PM2/6/12
to mq...@googlegroups.com
ahhh, that would explain a lot.. :)

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

DanAnderson

unread,
Feb 7, 2012, 12:29:45 AM2/7/12
to MQ Telemetry Transport
Hi,

Any client can send this message and the broker clears the retained
messages on the specific topic for all users?

Or am I misunderstanding?

Thanks
Dan

Sy

unread,
Feb 7, 2012, 2:38:10 AM2/7/12
to MQ Telemetry Transport
Certainly looks that way, these topics were originally created by a
process running on one of our servers. The topic was unpublished by
publishing the same topic with a blank payload.

Roger Light

unread,
Feb 7, 2012, 2:51:26 AM2/7/12
to mq...@googlegroups.com

Hi,

> Any client can send this message and the broker clears the retained
> messages on the specific topic for all users?

That's correct. The retained message doesn't belong to any user, so anybody can clear it - assuming they have permission to write to that topic of course.

Cheers,

Roger

DanAnderson

unread,
Feb 7, 2012, 3:55:57 AM2/7/12
to MQ Telemetry Transport
Hi,

Given that as true - is this a good idea?

If it doesn't belong to me - should I be able to delete it?

I'm speculating that a retained message might be important in some
scenarios.

Maybe the broker (or a specified client) should be the client that can
do this?

Thanks
Dan

Paul Fremantle

unread,
Feb 7, 2012, 4:19:25 AM2/7/12
to mq...@googlegroups.com
Surely this would be based on the topic security? In that case if I have the right to publish, I can replace the current retained message with any message I like, so deleting it is no worse.

I think this part of the spec ought to be a SHOULD not a MAY because it seems that there ought to be a standard way (rather than requiring out-of-band) to delete a topic.

Paul

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



--
Paul Fremantle
CTO and Co-Founder, WSO2
OASIS WS-RX TC Co-chair, VP, Apache Synapse

UK: +44 207 096 0336
US: +1 646 595 7614

blog: http://pzf.fremantle.org
twitter.com/pzfreo
pa...@wso2.com

wso2.com Lean Enterprise Middleware

Disclaimer: This communication may contain privileged or other confidential information and is intended exclusively for the addressee/s. If you are not the intended recipient/s, or believe that you may have received this communication in error, please reply to the sender indicating that fact and delete the copy you received and in addition, you should not print, copy, retransmit, disseminate, or otherwise use the information contained in this communication. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.

DanAnderson

unread,
Feb 7, 2012, 12:10:10 PM2/7/12
to MQ Telemetry Transport
Hi,

Yeah, I'm re-reading that and the respective section of the spec and
that makes sense.

So, anything you don't want messed with; you put into a separate topic
and set the security for that as you wish.

Probably hair-splitting: Does this "delete the topic"? What should
happen if there are QoS > 0, Clean Session = 0 messages pending
delivery on this topic?

Thanks
Dan

Nicholas O'Leary

unread,
Feb 7, 2012, 12:51:36 PM2/7/12
to mq...@googlegroups.com
Hi Dan,

No, this does not delete the topic - it just removes the retained message.

Nick
Reply all
Reply to author
Forward
0 new messages