From 26fa0501482bbf31c2a64a33f329ab9744ac3800 Mon Sep 17 00:00:00 2001 From: fuyou001 Date: Fri, 27 Oct 2023 16:28:17 +0800 Subject: [PATCH] [ISSUE #7501] The broker supports idempotence in creating topics (#7502) --- .../rocketmq/broker/processor/AdminBrokerProcessor.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java index 004bf12acdc..fbba6633b64 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java @@ -440,6 +440,13 @@ private synchronized RemotingCommand updateAndCreateTopic(ChannelHandlerContext return response; } + if (topicConfig.equals(this.brokerController.getTopicConfigManager().getTopicConfigTable().get(topic))) { + LOGGER.info("Broker receive request to update or create topic={}, but topicConfig has no changes , so idempotent, caller address={}", + requestHeader.getTopic(), RemotingHelper.parseChannelRemoteAddr(ctx.channel())); + response.setCode(ResponseCode.SUCCESS); + return response; + } + try { this.brokerController.getTopicConfigManager().updateTopicConfig(topicConfig); if (brokerController.getBrokerConfig().isEnableSingleTopicRegister()) {