You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/09/07 04:04:59 UTC

[GitHub] [rocketmq-spring] cj-8480 removed a comment on issue #294: GetAndWrapmessage method in rocketmqUtil is missing prefix when getting keys

cj-8480 removed a comment on issue #294:
URL: https://github.com/apache/rocketmq-spring/issues/294#issuecomment-688017664


   直接添加前缀会影响到其他类的使用的。
   我在自己补充了下面的方法,先行解决了
   <pre><code>
   private Message<?> convertToSpringMessage(org.apache.rocketmq.common.message.Message message) {
   	Message<?> convertToSpringMessage = RocketMQUtil.convertToSpringMessage(message);
   	// 转换Message补充KEYS参数,解决KEYS空BUG
   	// --- start ---
   	Message<?> targetMessage = null;
   	if (convertToSpringMessage instanceof GenericMessage) {
   		GenericMessage<?> sourceMessage = (GenericMessage<?>) convertToSpringMessage;
   		Map<String, Object> headers = new HashMap<>();
   		headers.putAll(sourceMessage.getHeaders());
   		headers.put(RocketMQHeaders.KEYS, message.getKeys());
   		targetMessage = new GenericMessage<>(sourceMessage.getPayload(), headers);
   	}
   	// --- end ---
   
   	return targetMessage;
   }
   </code></pre>
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org