本文整理汇总了Java中com.alibaba.rocketmq.common.message.MessageExt.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java MessageExt.getBody方法的具体用法?Java MessageExt.getBody怎么用?Java MessageExt.getBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.rocketmq.common.message.MessageExt
的用法示例。
在下文中一共展示了MessageExt.getBody方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRocketMqMessage
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
private void handleRocketMqMessage(List<MessageExt> msgs, MQMessageListener messageListner) {
for (MessageExt msg : msgs) {
MQMessage ceMessage = new MQMessage();
byte[] msgBody = msg.getBody();
ceMessage.setMessage(msgBody);
try {
messageListner.handle(ceMessage);
}
catch (Exception e) {
log.err(this, "MsgId=" + msg.getMsgId() + ",Topic=" + msg.getTopic() + ",MsgBornTimeStamp="
+ msg.getBornTimestamp() + "处理异常:" + e.getMessage(), e);
}
}
}
示例2: consumeMessage
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context) {
// TODO Auto-generated method stub
for (MessageExt msg : msgs) {
byte[] body = msg.getBody();
if (body.length == 2 && body[0] == 0 && body[1] == 0) {
LOG.error("Young:Got the end signal");
_collector.emit("stop",new Values("stop"));
continue;
}
if (msg.getTopic().equals(RaceConfig.MqPayTopic)) {
return doPayTopic(body);
}else if (msg.getTopic().equals(RaceConfig.MqTaobaoTradeTopic)) {
putTaobaoTradeToTair(body);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} else if (msg.getTopic().equals(RaceConfig.MqTmallTradeTopic)) {
putTmallTradeToTair(body);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}else {
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
示例3: consumeMessage
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
for (MessageExt msg : msgs) {
byte[] body = msg.getBody();
if (body.length == 2 && body[0] == 0 && body[1] == 0) {
LOG.error("Young:Got the end signal");
_collector.emit("stop",new Values("stop"));
continue;
}
if (msg.getTopic().equals(RaceConfig.MqPayTopic)) {
return doPayTopic(body);
}else if (msg.getTopic().equals(RaceConfig.MqTaobaoTradeTopic)) {
putTaobaoTradeToTair(body);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
} else if (msg.getTopic().equals(RaceConfig.MqTmallTradeTopic)) {
putTmallTradeToTair(body);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}else {
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
示例4: fromMessageExt
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
/**from Message**/
public static MessageView fromMessageExt(MessageExt messageExt) {
MessageView messageView = new MessageView();
BeanUtils.copyProperties(messageExt, messageView);
if (messageExt.getBody() != null) {
messageView.setMessageBody(new String(messageExt.getBody(), Charsets.UTF_8));
}
return messageView;
}
示例5: consumeMessage
import com.alibaba.rocketmq.common.message.MessageExt; //导入方法依赖的package包/类
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeConcurrentlyContext context)
{
LOGGER.info(" 当前处理的消息是 " + MessageHelp.GetMessagesToString(msgs));
MessageExt msg = msgs.get(0);
String strBody = null;
try
{
// 直接在第一次 字节转换字符串的时候就指定为 UTF-8 编码
strBody = new String(msg.getBody(), Encoding);
}
catch (UnsupportedEncodingException e1)
{
LOGGER.error("获取数据为UTF-8格式出错 ", e1);
strBody = new String(msg.getBody());
}
LOGGER.info("当前处理的消息 实体是 " + strBody);
// 消息处理次数的处理
if (msg.getReconsumeTimes() > count)
{
LOGGER.info("容错次数超出 msg=" + msg);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
return consumer.consumeMessage(strBody, msg, context);
}