Skip to content

Commit

Permalink
Add a config to determine whether pop response should return the actu…
Browse files Browse the repository at this point in the history
…al retry topic or tamper with the original topic
  • Loading branch information
fujian-zfj authored and RongtongJin committed Jul 17, 2023
1 parent 5914ff8 commit d43813a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ private CompletableFuture<Long> popMsgFromQueue(String attemptId, boolean isRetr
atomicRestNum.set(result.getMaxOffset() - result.getNextBeginOffset() + atomicRestNum.get());
String brokerName = brokerController.getBrokerConfig().getBrokerName();
for (SelectMappedBufferResult mapedBuffer : result.getMessageMapedList()) {
// We should not recode buffer for normal topic message
if (!isRetry) {
// We should not recode buffer when popResponseReturnActualRetryTopic is true or topic is not retry topic
if (brokerController.getBrokerConfig().isPopResponseReturnActualRetryTopic() || !isRetry) {
getMessageResult.addMessage(mapedBuffer);
} else {
List<MessageExt> messageExtList = MessageDecoder.decodesBatch(mapedBuffer.getByteBuffer(),
Expand Down
13 changes: 13 additions & 0 deletions common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ public class BrokerConfig extends BrokerIdentity {
*/
private long fetchNamesrvAddrInterval = 10 * 1000;

/**
* Pop response returns the actual retry topic rather than tampering with the original topic
*/
private boolean popResponseReturnActualRetryTopic = false;

public long getMaxPopPollingSize() {
return maxPopPollingSize;
}
Expand Down Expand Up @@ -1676,4 +1681,12 @@ public long getFetchNamesrvAddrInterval() {
public void setFetchNamesrvAddrInterval(final long fetchNamesrvAddrInterval) {
this.fetchNamesrvAddrInterval = fetchNamesrvAddrInterval;
}

public boolean isPopResponseReturnActualRetryTopic() {
return popResponseReturnActualRetryTopic;
}

public void setPopResponseReturnActualRetryTopic(boolean popResponseReturnActualRetryTopic) {
this.popResponseReturnActualRetryTopic = popResponseReturnActualRetryTopic;
}
}

0 comments on commit d43813a

Please sign in to comment.