Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Detect no retained message on subscribe(How can I find out, that there is no retained message, when I subscribe to a topic (Java))
Detect no retained message on subscribe [message #1787503] Sun, 27 May 2018 14:18
Peter Wensing is currently offline Peter WensingFriend
Messages: 1
Registered: May 2018
Junior Member
When I subscribe to a topic (Paho Java client), I want to initialize a hardware device from a retained MQTT message, if there is one on that topic.
Otherwise, I want to initialize it to a default value.
But I don't want to first initialize it to the default value and let it be changed, if the retained message arrives, because then my lights might be switched off an on again unnecessarily (which I want to avoid).

If there is a retained message, my provided callback method will be called and I can retrieve and use the message. In this case, everything is fine.

But if there is no retained message, the callback just won't be called and I seemingly can never be absolutely sure, whether there is no retained message or it just has not been processed yet.

The callback seems to always happen only, after the subscribe() method has returned.
So even the successful completion of that method without the callback being called, does not mean, that there is no retained message.

Currently, I use a timeout to decide, whether a retained message exists, but in my humble opinion there should be a better way.

I tried a number of things to find out, if there is such a way, but I couldn't find one.
Previous Topic:how do I install paho-mqtt on raspbian stretch python 3.5
Next Topic:Paho C++ embedded client code question
Goto Forum:
  


Current Time: Mon Sep 24 07:37:29 GMT 2018

Powered by FUDForum. Page generated in 0.01680 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top