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


Java ConsumeConcurrentlyStatus.CONSUME_SUCCESS属性代码示例

本文整理汇总了Java中com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus.CONSUME_SUCCESS属性的典型用法代码示例。如果您正苦于以下问题:Java ConsumeConcurrentlyStatus.CONSUME_SUCCESS属性的具体用法?Java ConsumeConcurrentlyStatus.CONSUME_SUCCESS怎么用?Java ConsumeConcurrentlyStatus.CONSUME_SUCCESS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus的用法示例。


在下文中一共展示了ConsumeConcurrentlyStatus.CONSUME_SUCCESS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: consumeMessage

@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,代码行数:26,代码来源:RaceSentenceSpout.java

示例2: consumeMessage

@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,代码行数:24,代码来源:SpoutLocal.java

示例3: equalsbody

/**
 *   匹配 body 消息实体的验证
 *   
 * @param matchingMap   注入的  匹配 规则 数据
 * @param MqTags        当前消费的MQ  Tags
 * @param Mqbody		当前转发的 消息 实体
 * @param Topic			需要转发到的 MQ Topic
 * @return
 */
private ConsumeConcurrentlyStatus equalsbody(Map<String, String> matchingMap, String MqTags,
		String Mqbody, String[] Topic)
{
	// 匹配 body
	if ("*".equals(matchingMap.get("body")))
	{
		// 不需要 匹配 Tag
		return sendMq(matchingMap, Mqbody, Topic);
	}

	if (!ForwardedHelp.isContains(Mqbody, matchingMap.get("body")))
	{
		LOGGER.debug("body 匹配未成功 放弃该消息    消息内容是   " + MqTags);
		return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
	}
	else
	{
		// 不需要 匹配 Tag
		return sendMq(matchingMap, Mqbody, Topic);
	}
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:30,代码来源:ForwardedMessageListConsumer.java

示例4: sendMq

/**
 *  将数据发送给MQ 
 * @param matchingMap   注入的配置数据
 * @param Mqbody	当前消息的 实体
 * @param Topic		转发的队列名称
 */
private ConsumeConcurrentlyStatus sendMq(Map<String, String> matchingMap, String Mqbody,
		String[] Topic)
{
	for (String topicval : Topic)
	{
		try
		{
			if (producer.send(topicval, matchingMap.get("Tags"), Mqbody) == null) { return ConsumeConcurrentlyStatus.RECONSUME_LATER; }
			return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
		}
		catch (UnsupportedEncodingException e)
		{
			LOGGER.error(" 异常 转发消息到MQ  失败  Tag= " + matchingMap.get("Topic") + " body= "
					+ Mqbody, e);
			return ConsumeConcurrentlyStatus.RECONSUME_LATER;
		}
	}
	return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:25,代码来源:ForwardedMessageListConsumer.java

示例5: consumeMessage

@Override
public ConsumeConcurrentlyStatus consumeMessage(String strBody, MessageExt msg,
		ConsumeConcurrentlyContext context)
{
	// TODO 待完善 日志系统
	for (Map<String, String> map : matching)
	{
		Map<String, String> params = new HashMap<String, String>();

		params.put("Topic", msg.getTopic());
		params.put("Tags", msg.getTags());

		if (externalCall == null) params.put("Body", strBody);
		else params.put("Body", externalCall.MessageConsumer(strBody, msg, context));

		return sendMqTags(map, msg.getTags(), params);
	}
	return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;

}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:20,代码来源:ExternalCallConcurrentlyStatus.java

示例6: equalsbody

/**
 *   匹配 body 消息实体的验证
 *   
 * @param matchingMap   注入的  匹配 规则 数据
 * @param MqTags        当前消费的MQ  Tags
 * @param Mqbody		当前转发的 消息 实体
 * @param Topic			需要转发到的 MQ Topic
 * @return
 */
private static ConsumeConcurrentlyStatus equalsbody(Map<String, String> matchingMap,
		String MqTags, String url, Map<String, String> params)
{
	// 匹配 body
	if ("*".equals(matchingMap.get("body")))
	{
		// 不需要 匹配 Tag
		return sendMq(matchingMap, url, params);
	}

	if (!ForwardedHelp.isContains(params.get("body"), matchingMap.get("body")))
	{
		LOGGER.debug("body 匹配未成功 放弃该消息    消息内容是   " + MqTags);
		return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
	}
	else
	{
		// 不需要 匹配 Tag
		return sendMq(matchingMap, url, params);
	}
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:30,代码来源:ExternalCallConcurrentlyStatus.java

示例7: createMessageListener

private MessageListener createMessageListener() {
    return new MessageListenerConcurrently() {
        AtomicLong consumeTimes = new AtomicLong(0);


        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
                ConsumeConcurrentlyContext context) {

            this.consumeTimes.incrementAndGet();
            if ((this.consumeTimes.get() % 11) == 0) {
                System.out.println("Delay 0========Receive New Messages: " + msgs);
                return ConsumeConcurrentlyStatus.RECONSUME_LATER;
            }
            else if ((this.consumeTimes.get() % 22) == 0) {
                System.out.println(Thread.currentThread().getName()
                        + "Delay 5========Receive New Messages: " + msgs);
                context.setDelayLevelWhenNextConsume(5);
                return ConsumeConcurrentlyStatus.RECONSUME_LATER;
            }
            System.out.println("No Delay========Receive New Messages: " + msgs);
            return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
        }
    };
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:25,代码来源:PushConsumerTest.java

示例8: consumeMessage

@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
    Message msg = msgs.get(0);
    String body = null;
    try {
        body = new String(msg.getBody(), "utf-8");
        if("test".equals(msg.getTopic())){
            logger.info(body);
        }
    } catch (Exception e) {
        logger.error("consumeMessage error, msg=" + msg.toString(), e);
        return ConsumeConcurrentlyStatus.RECONSUME_LATER;
    }
    return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
 
开发者ID:cairenjie1985,项目名称:springBoot-demo,代码行数:15,代码来源:MessageListener.java

示例9: consumeMessage

@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,代码行数:29,代码来源:DefaultMessageListener.java

示例10: consumeMessage

@Override
public ConsumeConcurrentlyStatus consumeMessage(String strBody, MessageExt msg,
		ConsumeConcurrentlyContext context)
{
	LOGGER.info("\n 当前线程是" + Thread.currentThread().getId() + "  \n 数据是" + strBody);
	return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:7,代码来源:ConsumableMessageListenerConsumer.java

示例11: consumeMessage

@Override
public ConsumeConcurrentlyStatus consumeMessage(String strBody, MessageExt msg,
		ConsumeConcurrentlyContext context)
{
	for (Map<String, String> map : matching)
	{
		if (forwarded != null) strBody = forwarded.MessageConsumer(strBody, msg, context);
		return sendMqTags(map, msg.getTags(), strBody);
	}
	return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:11,代码来源:ForwardedMessageListConsumer.java

示例12: equalsTag

/**
 *   匹配 Tag 消息 Tag 的验证
 *   
 * @param matchingMap   注入的  匹配 规则 数据
 * @param MqTags        当前消费的MQ  Tags
 * @param Mqbody		当前转发的 消息 实体
 * @param Topic			需要转发到的 MQ Topic
 * @return
 */
private ConsumeConcurrentlyStatus equalsTag(Map<String, String> matchingMap, String MqTags,
		String Mqbody)
{
	String[] Topic = matchingMap.get("Topic").split(",");

	// 是否需要 匹配 Tag
	if ("*".equals(matchingMap.get("Tag")))
	{
		// 不需要匹配
		// 匹配 body
		return equalsbody(matchingMap, MqTags, Mqbody, Topic);
	}
	else
	{
		// 进行匹配 Tag
		if (ForwardedHelp.isContains(MqTags, matchingMap.get("Tag")))
		{
			// 匹配成功 进行 匹配 body
			return equalsbody(matchingMap, MqTags, Mqbody, Topic);
		}
		else
		{
			LOGGER.debug("Tag 匹配未成功 放弃该消息    消息内容是   " + MqTags);
			return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
		}
	}
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:36,代码来源:ForwardedMessageListConsumer.java

示例13: equalsTag

/**
 *   匹配 Tag 消息 Tag 的验证
 *   
 * @param matchingMap   注入的  匹配 规则 数据
 * @param MqTags        当前消费的MQ  Tags
 * @param Mqbody		当前转发的 消息 实体
 * @param Topic			需要转发到的 MQ Topic
 * @return
 */
private static ConsumeConcurrentlyStatus equalsTag(Map<String, String> matchingMap,
		String MqTags, Map<String, String> params)
{
	String url = matchingMap.get("url");

	// 是否需要 匹配 Tag
	if ("*".equals(matchingMap.get("Tag")))
	{
		// 不需要匹配
		// 匹配 body
		return equalsbody(matchingMap, MqTags, url, params);

	}
	else
	{
		// 进行匹配 Tag
		if (ForwardedHelp.isContains(MqTags, matchingMap.get("Tag")))
		{
			// 匹配成功 进行 匹配 body
			return equalsbody(matchingMap, MqTags, url, params);
		}
		else
		{
			LOGGER.debug("Tag 匹配未成功 放弃该消息    消息内容是   " + MqTags);
			return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
		}
	}
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:37,代码来源:ExternalCallConcurrentlyStatus.java

示例14: sendMq

/**
 * @param matchingMap
 * @param mqbody
 * @param url
 * @return
 */
private static ConsumeConcurrentlyStatus sendMq(Map<String, String> matchingMap, String url,
		Map<String, String> params)
{

	HttpResponse resp = HttpRequest.sendPostMessage(url, params, "UTF-8");
	if (resp == null || resp.getState() != 200) { return ConsumeConcurrentlyStatus.RECONSUME_LATER; }
	return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
 
开发者ID:atliwen,项目名称:rocketMqCurrency,代码行数:14,代码来源:ExternalCallConcurrentlyStatus.java

示例15: consumeMessage

@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
		ConsumeConcurrentlyContext context) {
	try {
		MetaTuple metaTuple = new MetaTuple(msgs, context.getMessageQueue());

		if (flowControl) {
			sendingQueue.offer(metaTuple);
		} else {
			sendTuple(metaTuple);
		}

		if (autoAck) {
			return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
		} else {
			metaTuple.waitFinish();
			if (metaTuple.isSuccess() == true) {
				return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
			} else {
				return ConsumeConcurrentlyStatus.RECONSUME_LATER;
			}
		}

	} catch (Exception e) {
		LOG.error("Failed to emit " + id, e);
		return ConsumeConcurrentlyStatus.RECONSUME_LATER;
	}

}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:29,代码来源:MetaSpout.java


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