Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding subscription acknowledgement failure error #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.eclipse.paho.client.mqttv3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@
</plugins>
</pluginManagement>
</build>
<version>1.2.7.timer-ping-sender</version>
<version>1.2.8.mqtt-suback-failure</version>
</project>

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.eclipse.paho.client.mqttv3;

import java.util.List;

/**
* Implementors of this interface will be notified when an asynchronous action completes.
*
Expand Down Expand Up @@ -27,4 +29,8 @@ public interface IMqttActionListener {
* @param exception thrown by the action that has failed
*/
void onFailure(IMqttToken asyncActionToken, Throwable exception);

default void onSubscribeResult(List<String> successTopics, List<String> failedTopics) {
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.eclipse.paho.client.mqttv3.internal;

import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
Expand All @@ -33,10 +34,7 @@
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttToken;
import org.eclipse.paho.client.mqttv3.MqttTopic;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttPubAck;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttPubComp;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttPublish;
import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage;
import org.eclipse.paho.client.mqttv3.internal.wire.*;
import org.eclipse.paho.client.mqttv3.logging.Logger;
import org.eclipse.paho.client.mqttv3.logging.LoggerFactory;

Expand Down Expand Up @@ -326,7 +324,14 @@ public void fireActionEvent(MqttToken token) {
if (token != null) {
IMqttActionListener asyncCB = token.getActionCallback();
if (asyncCB != null) {
if (token.getException() == null) {
if (
token.getResponse() instanceof MqttSuback &&
Arrays.stream(((MqttSuback) token.getResponse()).getGrantedQos()).anyMatch(argument -> argument == 128)
) {
log.fine(CLASS_NAME, methodName, "716",
new Object[] { token.internalTok.getKey() });
asyncCB.onFailure(token, new IllegalStateException("the mqtt subscription failed"));
} else if (token.getException() == null) {
// @TRACE 716=call onSuccess key={0}
log.fine(CLASS_NAME, methodName, "716",
new Object[] { token.internalTok.getKey() });
Expand Down