Java Code Examples for com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus#RECONSUME_LATER

The following examples show how to use com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus#RECONSUME_LATER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForwardedMessageListConsumer.java    From RocketMqCurrencyBoot with Apache License 2.0 6 votes vote down vote up
/**
 *    验证规则 并按照规则将数据 转发到对应的 队列中
 */
private ConsumeConcurrentlyStatus sendMqTags(Map<String, String> matchingMap, String MqTags,
		String Mqbody)
{
	// 验证是否有空值
	String[] keys =
	{ "Tag", "body", "Topic", "Tags" };

	try
	{
		ForwardedHelp.outStr(matchingMap, keys);
	}
	catch (Exception e)
	{
		LOGGER.error(" 转发消费端  验证规则 并按照规则将数据 转发到对应的 ", e.getMessage());
		return ConsumeConcurrentlyStatus.RECONSUME_LATER;
	}

	return equalsTag(matchingMap, MqTags, Mqbody);

}
 
Example 2
Source File: ForwardedMessageListConsumer.java    From RocketMqCurrencyBoot with Apache License 2.0 6 votes vote down vote up
/**
 *  将数据发送给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;
}
 
Example 3
Source File: ExternalCallConcurrentlyStatus.java    From RocketMqCurrencyBoot with Apache License 2.0 6 votes vote down vote up
/**
 *    验证规则 并按照规则将数据 转发到对应的 队列中  
 */
public ConsumeConcurrentlyStatus sendMqTags(Map<String, String> matchingMap, String MqTags,
		Map<String, String> params, String strBody, MessageExt msg,
		ConsumeConcurrentlyContext context)
{
	// 验证是否有空值
	String[] keys =
	{ "url", "Tag", "body" };
	try
	{
		ForwardedHelp.outStr(matchingMap, keys);
	}
	catch (Exception e)
	{
		LOGGER.error(e.getMessage());
		return ConsumeConcurrentlyStatus.RECONSUME_LATER;
	}

	return forwardedWebDate(matchingMap, MqTags, params, msg, context);

}
 
Example 4
Source File: MessageConcurrentlyConsumeInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    Object ret) throws Throwable {
    ConsumeConcurrentlyStatus status = (ConsumeConcurrentlyStatus) ret;
    if (status == ConsumeConcurrentlyStatus.RECONSUME_LATER) {
        AbstractSpan activeSpan = ContextManager.activeSpan();
        activeSpan.errorOccurred();
        Tags.STATUS_CODE.set(activeSpan, status.name());
    }
    ContextManager.stopSpan();
    return ret;
}
 
Example 5
Source File: MetaSpout.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@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 {
            if (!conf.get(LoadConfig.TOPOLOGY_TYPE).equals("Trident")) {
                metaTuple.waitFinish();
            }
            if (metaTuple.isSuccess()) {
                return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
            } else {
                return ConsumeConcurrentlyStatus.RECONSUME_LATER;
            }
        }

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

}