Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,6 @@ protected final void sendQoS0SubMessage(RoutedMessage msg) {
write(pubMsg).addListener(f -> {
memUsage.addAndGet(-msgSize);
if (f.isSuccess()) {
lastActiveAtNanos = sessionCtx.nanoTime();
if (settings.debugMode) {
eventCollector.report(getLocal(QoS0Pushed.class)
.isRetain(msg.isRetain())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.apache.bifromq.mqtt.handler.MQTTSessionIdUtil.userSessionId;
import static org.apache.bifromq.plugin.eventcollector.EventType.DISCARD;
import static org.apache.bifromq.plugin.eventcollector.EventType.EXCEED_RECEIVING_LIMIT;
import static org.apache.bifromq.plugin.eventcollector.EventType.IDLE;
import static org.apache.bifromq.plugin.eventcollector.EventType.INVALID_TOPIC;
import static org.apache.bifromq.plugin.eventcollector.EventType.INVALID_TOPIC_FILTER;
import static org.apache.bifromq.plugin.eventcollector.EventType.MALFORMED_TOPIC;
Expand Down Expand Up @@ -728,6 +729,35 @@ public void qos0Pub() {
verifyEvent(MQTT_SESSION_START, QOS0_PUSHED, QOS0_PUSHED, QOS0_PUSHED, QOS0_PUSHED, QOS0_PUSHED);
}

@Test
public void qos0PubDoesNotRefreshSessionKeepAlive() {
mockCheckPermission(true);
mockDistMatch(true);
transientSessionHandler.subscribe(System.nanoTime(), topicFilter, QoS.AT_MOST_ONCE);
channel.runPendingTasks();
ArgumentCaptor<Long> longCaptor = ArgumentCaptor.forClass(Long.class);
verify(localDistService).match(anyLong(), eq(topicFilter), longCaptor.capture(), any());

testTicker.advanceTimeBy(100, TimeUnit.SECONDS);
channel.advanceTimeBy(100, TimeUnit.SECONDS);
channel.runScheduledPendingTasks();
assertTrue(channel.isActive());

transientSessionHandler.publish(s2cMessageList(topic, 1, QoS.AT_MOST_ONCE),
Collections.singleton(new IMQTTTransientSession.MatchedTopicFilter(topicFilter, longCaptor.getValue())));
channel.runPendingTasks();
MqttPublishMessage message = channel.readOutbound();
assertEquals(message.fixedHeader().qosLevel().value(), QoS.AT_MOST_ONCE_VALUE);
assertEquals(message.variableHeader().topicName(), topic);

testTicker.advanceTimeBy(81, TimeUnit.SECONDS);
channel.advanceTimeBy(81, TimeUnit.SECONDS);
channel.runScheduledPendingTasks();

assertFalse(channel.isActive());
verifyEvent(MQTT_SESSION_START, QOS0_PUSHED, IDLE);
}

@Test
public void qos0PubExceedBufferCapacity() {
mockCheckPermission(true);
Expand Down
Loading