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

fix: mqtt-kafka routing fix #1402

Merged
merged 2 commits into from
Feb 14, 2025
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 @@ -192,7 +192,7 @@ public MessageConsumer newStream(
}
else
{
// JRF: can we remove this? current used by will stream which arrives proactively, so no affinity
// JRF: can we remove this? current used by will stream which arrives proactively, so no compositeId
Optional<AsyncapiRouteConfig> routeRef = binding.routes.stream().findFirst();
final long resolvedId = routeRef.map(r -> r.id).orElse(0L);
final long resolvedApiId = routeRef.map(r -> composite.resolveApiId(r.with.apiId)).orElse(0L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ private MqttSessionProxy(
this.resolvedId = resolvedId;
this.initialId = initialId;
this.replyId = supplyReplyId.applyAsLong(initialId);
this.session = new KafkaFetchWillSignalStream(originId, resolvedId, this);
this.session = new KafkaFetchWillSignalStream(routedId, resolvedId, this);
this.sessionsTopic = sessionsTopic;
this.sessionId = new String16FW(sessionIds.get(bindingId));
this.leaderEpochs = new Long2LongHashMap(-2);
Expand Down Expand Up @@ -570,8 +570,7 @@ private void onMqttBegin(

if (!isSetWillFlag(sessionFlags) || isSetCleanStart(sessionFlags))
{
final long routedId = session.routedId;
session = new KafkaSessionSignalStream(originId, routedId, this);
session = new KafkaSessionSignalStream(routedId, resolvedId, this);
}
if (isSetWillFlag(sessionFlags))
{
Expand Down Expand Up @@ -1145,13 +1144,13 @@ private void openMetaStreams(
messagesTopics.forEach(t ->
{
final KafkaMetaStream meta =
new KafkaMetaStream(originId, resolvedId, this, t, false);
new KafkaMetaStream(routedId, resolvedId, this, t, false);
metas.add(meta);
meta.doKafkaBegin(traceId, authorization, 0);
});

final KafkaMetaStream retainedMeta =
new KafkaMetaStream(originId, resolvedId, this, retainedTopic, true);
new KafkaMetaStream(routedId, resolvedId, this, retainedTopic, true);
metas.add(retainedMeta);
retainedMeta.doKafkaBegin(traceId, authorization, 0);
}
Expand Down Expand Up @@ -1198,8 +1197,7 @@ private void onSessionBecomesLeader(

if (publishQosMax < 2)
{
final long routedId = session.routedId;
session = new KafkaSessionStateProxy(originId, routedId, this);
session = new KafkaSessionStateProxy(routedId, resolvedId, this);
session.doKafkaBeginIfNecessary(traceId, authorization, 0);
}
else
Expand Down Expand Up @@ -1266,8 +1264,7 @@ private void onOffsetFetched(

if (unfetchedKafkaTopics == 0 && initProducer)
{
final long routedId = session.routedId;
producerInit = new KafkaInitProducerStream(originId, routedId, this);
producerInit = new KafkaInitProducerStream(routedId, resolvedId, this);
producerInit.doKafkaBegin(traceId, authorization, 0);
}
else if (unfetchedKafkaTopics == 0)
Expand Down Expand Up @@ -1308,8 +1305,7 @@ private void onProducerInit(
long traceId,
long authorization)
{
final long routedId = session.routedId;
offsetCommit = new KafkaOffsetCommitStream(originId, routedId, this, groupHost, groupPort);
offsetCommit = new KafkaOffsetCommitStream(routedId, resolvedId, this, groupHost, groupPort);
offsetCommit.doKafkaBegin(traceId, authorization, 0);
}

Expand Down Expand Up @@ -1388,7 +1384,7 @@ private void doFetchOffsetMetadata(
final String topic0 = topic.asString();

final KafkaOffsetFetchStream offsetFetch =
new KafkaOffsetFetchStream(originId, resolvedId, this, groupHost, groupPort, topic0, partitions);
new KafkaOffsetFetchStream(routedId, resolvedId, this, groupHost, groupPort, topic0, partitions);
offsetFetches.add(offsetFetch);
offsetFetch.doKafkaBegin(traceId, authorization, 0);
}
Expand Down Expand Up @@ -1473,7 +1469,7 @@ private void doCreateSessionStream(
}).build();

doMqttBegin(traceId, authorization, 0, mqttBeginEx);
session = new KafkaSessionStateProxy(originId, resolvedId, this);
session = new KafkaSessionStateProxy(routedId, resolvedId, this);
session.doKafkaBeginIfNecessary(traceId, authorization, 0);
}
}
Expand Down