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.common.utilities.BitConverter;
import org.enodeframework.queue.QueueMessage;
/**
* @author [email protected]
*/
public class RocketMQTool {
public static QueueMessage covertToQueueMessage(MessageExt messageExt) {
QueueMessage queueMessage = new QueueMessage();
queueMessage.setBody(BitConverter.toString(messageExt.getBody()));
queueMessage.setTopic(messageExt.getTopic());
queueMessage.setTag(messageExt.getTags());
queueMessage.setKey(messageExt.getKeys());
return queueMessage;
}
public static Message covertToProducerRecord(QueueMessage queueMessage) {
return new Message(queueMessage.getTopic(), queueMessage.getTag(), queueMessage.getKey(), BitConverter.getBytes(queueMessage.getBody()));
}
}