org.enodeframework.rocketmq.message.RocketMQTool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enode-rocketmq Show documentation
Show all versions of enode-rocketmq Show documentation
enodeframework message queue rocketmq adapter
package org.enodeframework.rocketmq.message;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;
import org.enodeframework.queue.QueueMessage;
import java.nio.charset.StandardCharsets;
/**
* @author [email protected]
*/
public class RocketMQTool {
public static QueueMessage covertToQueueMessage(MessageExt messageExt) {
QueueMessage queueMessage = new QueueMessage();
queueMessage.setBody(new String(messageExt.getBody(), StandardCharsets.UTF_8));
queueMessage.setTopic(messageExt.getTopic());
queueMessage.setTag(messageExt.getTags());
queueMessage.setKey(messageExt.getKeys());
return queueMessage;
}
public static Message covertToProducerRecord(QueueMessage queueMessage) {
Message message = new Message(queueMessage.getTopic(), queueMessage.getTag(), queueMessage.getKey(), queueMessage.getBody().getBytes(StandardCharsets.UTF_8));
return message;
}
}