当前位置: 首页>>代码示例>>Java>>正文


Java MessageExt.getBody方法代码示例

本文整理汇总了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);
            }
        }

    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:18,代码来源:RocketMQConsumer.java

示例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;  
}
 
开发者ID:yangliguang,项目名称:preliminary.demo,代码行数:27,代码来源:RaceSentenceSpout.java

示例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;  
}
 
开发者ID:yangliguang,项目名称:preliminary.demo,代码行数:25,代码来源:SpoutLocal.java

示例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;
    }
 
开发者ID:didapinchegit,项目名称:rocket-console,代码行数:11,代码来源:MessageView.java

示例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);
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:30,代码来源:DefaultMessageListener.java


注:本文中的com.alibaba.rocketmq.common.message.MessageExt.getBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。