Skip to content

Commit

Permalink
[ISSUE apache#7845] Simplify the AbstractSendMessageProcessor#buildMs…
Browse files Browse the repository at this point in the history
…gContext code using Optional (apache#7846)
  • Loading branch information
mxsm authored Feb 29, 2024
1 parent 3877dcd commit eed303d
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.net.SocketAddress;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.rocketmq.broker.BrokerController;
Expand Down Expand Up @@ -370,15 +371,12 @@ protected SendMessageContext buildMsgContext(ChannelHandlerContext ctx,
sendMessageContext.setCommercialOwner(owner);

Map<String, String> properties = MessageDecoder.string2messageProperties(requestHeader.getProperties());
String uniqueKey = properties.get(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
properties.put(MessageConst.PROPERTY_MSG_REGION, this.brokerController.getBrokerConfig().getRegionId());
properties.put(MessageConst.PROPERTY_TRACE_SWITCH, String.valueOf(this.brokerController.getBrokerConfig().isTraceOn()));
requestHeader.setProperties(MessageDecoder.messageProperties2String(properties));

if (uniqueKey == null) {
uniqueKey = "";
}
sendMessageContext.setMsgUniqueKey(uniqueKey);
String uniqueKey = properties.get(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
sendMessageContext.setMsgUniqueKey(Optional.ofNullable(uniqueKey).orElse(""));

if (properties.containsKey(MessageConst.PROPERTY_SHARDING_KEY)) {
sendMessageContext.setMsgType(MessageType.Order_Msg);
Expand Down

0 comments on commit eed303d

Please sign in to comment.