|
27 | 27 | import java.util.concurrent.ConcurrentSkipListSet; |
28 | 28 | import java.util.concurrent.TimeUnit; |
29 | 29 | import java.util.concurrent.atomic.AtomicLong; |
| 30 | +import org.apache.commons.lang3.StringUtils; |
30 | 31 | import org.apache.rocketmq.broker.BrokerController; |
31 | 32 | import org.apache.rocketmq.common.KeyBuilder; |
| 33 | +import org.apache.rocketmq.common.MixAll; |
32 | 34 | import org.apache.rocketmq.common.PopAckConstants; |
33 | 35 | import org.apache.rocketmq.common.ServiceThread; |
34 | 36 | import org.apache.rocketmq.common.constant.LoggerName; |
| 37 | +import org.apache.rocketmq.common.message.MessageConst; |
35 | 38 | import org.apache.rocketmq.logging.org.slf4j.Logger; |
36 | 39 | import org.apache.rocketmq.logging.org.slf4j.LoggerFactory; |
37 | 40 | import org.apache.rocketmq.remoting.CommandCallback; |
| 41 | +import org.apache.rocketmq.remoting.netty.NettyRemotingAbstract; |
38 | 42 | import org.apache.rocketmq.remoting.netty.NettyRequestProcessor; |
39 | 43 | import org.apache.rocketmq.remoting.netty.RequestTask; |
| 44 | +import org.apache.rocketmq.remoting.protocol.NamespaceUtil; |
40 | 45 | import org.apache.rocketmq.remoting.protocol.RemotingCommand; |
41 | | -import org.apache.rocketmq.remoting.netty.NettyRemotingAbstract; |
42 | 46 | import org.apache.rocketmq.remoting.protocol.heartbeat.SubscriptionData; |
43 | 47 | import org.apache.rocketmq.store.ConsumeQueueExt; |
44 | 48 | import org.apache.rocketmq.store.MessageFilter; |
@@ -167,13 +171,31 @@ public void notifyMessageArrivingWithRetryTopic(final String topic, final int qu |
167 | 171 |
|
168 | 172 | public void notifyMessageArrivingWithRetryTopic(final String topic, final int queueId, long offset, |
169 | 173 | Long tagsCode, long msgStoreTime, byte[] filterBitMap, Map<String, String> properties) { |
170 | | - String notifyTopic; |
171 | | - if (KeyBuilder.isPopRetryTopicV2(topic)) { |
172 | | - notifyTopic = KeyBuilder.parseNormalTopic(topic); |
| 174 | + if (NamespaceUtil.isRetryTopic(topic)) { |
| 175 | + notifyMessageArrivingFromRetry(topic, queueId, tagsCode, msgStoreTime, filterBitMap, properties); |
173 | 176 | } else { |
174 | | - notifyTopic = topic; |
| 177 | + notifyMessageArriving(topic, queueId, offset, tagsCode, msgStoreTime, filterBitMap, properties); |
| 178 | + } |
| 179 | + } |
| 180 | + |
| 181 | + private void notifyMessageArrivingFromRetry(String topic, int queueId, Long tagsCode, long msgStoreTime, byte[] filterBitMap, |
| 182 | + Map<String, String> properties) { |
| 183 | + String prefix = MixAll.RETRY_GROUP_TOPIC_PREFIX; |
| 184 | + String originGroup = properties.get(MessageConst.PROPERTY_ORIGIN_GROUP); |
| 185 | + // In the case of pop consumption, there is no long polling hanging on the retry topic, so the wake-up is skipped. |
| 186 | + if (StringUtils.isBlank(originGroup)) { |
| 187 | + return; |
| 188 | + } |
| 189 | + // %RETRY%GROUP is used for pull mode, so the wake-up is skipped. |
| 190 | + int originTopicStartIndex = prefix.length() + originGroup.length() + 1; |
| 191 | + if (topic.length() <= originTopicStartIndex) { |
| 192 | + return; |
| 193 | + } |
| 194 | + String originTopic = topic.substring(originTopicStartIndex); |
| 195 | + if (queueId >= 0) { |
| 196 | + notifyMessageArriving(originTopic, -1, originGroup, true, tagsCode, msgStoreTime, filterBitMap, properties); |
175 | 197 | } |
176 | | - notifyMessageArriving(notifyTopic, queueId, offset, tagsCode, msgStoreTime, filterBitMap, properties); |
| 198 | + notifyMessageArriving(originTopic, queueId, originGroup, true, tagsCode, msgStoreTime, filterBitMap, properties); |
177 | 199 | } |
178 | 200 |
|
179 | 201 | public void notifyMessageArriving(final String topic, final int queueId, long offset, |
|
0 commit comments