← Back to team overview

mosquitto-users team mailing list archive

Re: Retained messages

 

Hi Stefano,

The retained flag has different meanings depending on whether a
message is going from the client to the broker or broker to client.
For a message from the client to the broker, if the retained flag is
set the client is telling the broker that this message should be
retained as the last known good value. When a message from the broker
to the client has the retained flag set, the broker is telling the
client that this message is not fresh - it may have been sat as a
retained value for a long time. This will only happen when the client
first subscribes to a topic with the first set of messages received.
All messages after this are sent to the client as soon as they are
received. The upshot is that a client with a subscription has no way
of knowing if a message was intended to be retained or not.

Both mosquitto and rsmb implement a mode where if a client sets the
MSB of the protocol version byte in the CONNECT command (i.e. the
protocol version is 0x83 instead of 0x03) then it is telling the
broker that it is a bridge. This means that retained message state is
propagated, which is what you want. It also means that any messages
the client sends to the broker are not echoed back to it which is
important to help prevent message loops. This functionality is not
currently part of the spec, but I anticipate that it will be in the
next revision.

Cheers,

Roger


On Tue, Sep 18, 2012 at 8:55 AM, stefano costa
<stefano.costa@xxxxxxxxxxx> wrote:
> Hello,
> we're developing a simple application (daemon) that will create an history
> of messages published on a broker, more on this as soon as I have a first
> draft of the architecture. This is related to a product under development
> but I think it could be useful also to others.
>
> In order to be as generic as possible it would be useful to have a chance of
> knowing if a message that I receive as a subscriber to a broker has been
> published with the "retained" flag set. Is this piece of information
> available? I didn't find any indication from the subscriber point of view.
>
> Thanks S.
>
> --
>   Stefano Costa, R&D Manager
>   M +39 335 6565749
>   Skype stefanocosta.bluewind
>   http://www.bluewind.it/stefanoco?code=9
>
>
> --
> Mailing list: https://launchpad.net/~mosquitto-users
> Post to     : mosquitto-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~mosquitto-users
> More help   : https://help.launchpad.net/ListHelp


Follow ups

References