Skip to content
Merged
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 @@ -1818,6 +1818,7 @@ final class KafkaRetainedProxy extends KafkaProxy
private final long replyId;
private final MqttSubscribeProxy mqtt;
private final Int2ObjectHashMap<IntArrayList> incompletePacketIds;
private final IntArrayList unAckedPacketIds;

private int state;

Expand All @@ -1844,6 +1845,7 @@ private KafkaRetainedProxy(
this.initialId = supplyInitialId.applyAsLong(routedId);
this.replyId = supplyReplyId.applyAsLong(initialId);
this.incompletePacketIds = new Int2ObjectHashMap<>();
this.unAckedPacketIds = new IntArrayList();
}

private void doKafkaBegin(
Expand Down Expand Up @@ -1910,16 +1912,20 @@ protected void doKafkaConsumerFlush(
{
incompletePacketIds.remove(offset.partitionId);
}
if (incompletePacketIds.isEmpty())
{
shouldClose = true;
}
}
else if (state == MqttOffsetStateFlags.INCOMPLETE)

unAckedPacketIds.removeInt(packetId);

if (state == MqttOffsetStateFlags.INCOMPLETE)
{
incompletePacketIds.computeIfAbsent(offset.partitionId, c -> new IntArrayList()).add(packetId);
}

if (unAckedPacketIds.isEmpty() && incompletePacketIds.isEmpty())
{
shouldClose = true;
}

final int correlationId = state == MqttOffsetStateFlags.INCOMPLETE ? packetId : -1;

final KafkaFlushExFW kafkaFlushEx =
Expand Down Expand Up @@ -2166,6 +2172,7 @@ private void onKafkaData(
final int packetId = packetIdCounter.getAndIncrement();
offsetsPerPacketId.put(packetId,
new PartitionOffset(topicKey, partition.partitionId(), partition.partitionOffset()));
unAckedPacketIds.add(packetId);
b.packetId(packetId);
b.qos(qos);
}
Expand Down Expand Up @@ -2288,12 +2295,12 @@ private void onKafkaFlush(
mqtt.doMqttFlush(traceId, authorization, budgetId, reserved, mqttSubscribeFlushEx);
}
}
if (offsetsPerPacketId.isEmpty())
if (unAckedPacketIds.isEmpty() && incompletePacketIds.isEmpty())
{
mqtt.retainedSubscriptionIds.clear();
doKafkaEnd(traceId, authorization);
}
else if (!incompletePacketIds.isEmpty())
else
{
incompletePacketIds.forEach((partitionId, metadata) ->
metadata.forEach(packetId ->
Expand Down