Skip to content

Commit 2976b25

Browse files
committed
client enhancement
1 parent 4a4d8a5 commit 2976b25

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumer/SubscriptionManager.java

+6-17
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,19 @@ public void updateSubscription(ClientInfo clientInfo, String consumerGroup,
114114
if (CollectionUtils.isEmpty(groupTopicClients)) {
115115
log.error("group {} topic {} clients is empty", consumerGroup, subscription);
116116
}
117+
ConsumerGroupConf consumerGroupConf = localConsumerGroupMapping.computeIfAbsent(consumerGroup, (consumerGroupInner) ->
118+
new ConsumerGroupConf(consumerGroup)
119+
);
117120

118-
ConsumerGroupConf consumerGroupConf = localConsumerGroupMapping.get(consumerGroup);
119-
if (consumerGroupConf == null) {
120-
// new subscription
121-
ConsumerGroupConf prev = localConsumerGroupMapping.putIfAbsent(consumerGroup, new ConsumerGroupConf(consumerGroup));
122-
if (prev == null) {
123-
log.info("add new subscription, consumer group: {}", consumerGroup);
124-
}
125-
consumerGroupConf = localConsumerGroupMapping.get(consumerGroup);
126-
}
127-
128-
ConsumerGroupTopicConf consumerGroupTopicConf = consumerGroupConf.getConsumerGroupTopicConf()
129-
.get(subscription.getTopic());
130-
if (consumerGroupTopicConf == null) {
131-
consumerGroupConf.getConsumerGroupTopicConf().computeIfAbsent(subscription.getTopic(), (topic) -> {
121+
ConsumerGroupTopicConf consumerGroupTopicConf =
122+
consumerGroupConf.getConsumerGroupTopicConf().computeIfAbsent(subscription.getTopic(), (topicInner) -> {
132123
ConsumerGroupTopicConf newTopicConf = new ConsumerGroupTopicConf();
133124
newTopicConf.setConsumerGroup(consumerGroup);
134-
newTopicConf.setTopic(topic);
125+
newTopicConf.setTopic(topicInner);
135126
newTopicConf.setSubscriptionItem(subscription);
136127
log.info("add new {}", newTopicConf);
137128
return newTopicConf;
138129
});
139-
consumerGroupTopicConf = consumerGroupConf.getConsumerGroupTopicConf().get(subscription.getTopic());
140-
}
141130

142131
consumerGroupTopicConf.getUrls().add(url);
143132
if (!consumerGroupTopicConf.getIdcUrls().containsKey(clientInfo.getIdc())) {

0 commit comments

Comments
 (0)