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 @@ -828,9 +828,18 @@ private void doMqttWindow(
int padding,
int capabilities)
{
final boolean retainedFlag = hasPublishFlagRetained(publishFlags);
final long newInitialAck = retainedFlag ? Math.min(messages.initialAck, retained.initialAck) : messages.initialAck;
final int newInitialMax = retainedFlag ? Math.max(messages.initialMax, retained.initialMax) : messages.initialMax;
// messages and retained advertise credit differently - messages holds its ack at zero
// and grows its max, retained advances its ack against a fixed max - so minimizing ack
// and max independently would combine the ack of one with the max of the other and cap
// the stream for its whole lifetime; compare the budgets each one actually offers
final int messagesBudget = messages.initialMax - (int)(messages.initialSeq - messages.initialAck);
final int retainedBudget = retained.initialMax - (int)(retained.initialSeq - retained.initialAck);
final int newInitialBudget = retainAvailable ?
Math.min(messagesBudget, retainedBudget) : messagesBudget;
final int newInitialMax = retainAvailable ?
Math.min(messages.initialMax, retained.initialMax) : messages.initialMax;
final long newInitialAck =
Math.max(initialAck, initialSeq - Math.max(newInitialMax - newInitialBudget, 0));

if (MqttKafkaState.initialOpened(messages.state) &&
(!retainAvailable || MqttKafkaState.initialOpened(retained.state)) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ public void shouldPublishRetainedMessage() throws Exception
k3po.finish();
}

@Test
@Configuration("proxy.yaml")
@Configure(name = WILL_AVAILABLE_NAME, value = "false")
@Specification({
"${mqtt}/publish.many.messages.retain.available/client",
"${kafka}/publish.many.messages.retain.available/server"})
public void shouldPublishManyMessagesRetainAvailable() throws Exception
{
k3po.finish();
}

@Test
@Configuration("proxy.yaml")
@Configure(name = WILL_AVAILABLE_NAME, value = "false")
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ public void shouldPublishRetainedMessage() throws Exception
k3po.finish();
}

@Test
@Specification({
"${kafka}/publish.many.messages.retain.available/client",
"${kafka}/publish.many.messages.retain.available/server"})
public void shouldPublishManyMessagesRetainAvailable() throws Exception
{
k3po.finish();
}

@Test
@Specification({
"${kafka}/publish.multiple.messages/client",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ public void shouldPublishRetainedMessage() throws Exception
k3po.finish();
}

@Test
@Specification({
"${mqtt}/publish.many.messages.retain.available/client",
"${mqtt}/publish.many.messages.retain.available/server"})
public void shouldPublishManyMessagesRetainAvailable() throws Exception
{
k3po.finish();
}

@Test
@Specification({
"${mqtt}/publish.with.user.properties.distinct/client",
Expand Down
Loading