Java Code Examples for com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus#CONSUME_SUCCESS
The following examples show how to use
com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus#CONSUME_SUCCESS .
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 |
@Override public ConsumeConcurrentlyStatus consumeMessage(String strBody, MessageExt msg, ConsumeConcurrentlyContext context) { if (baseMatching != null) { List<Map<String, String>> me = baseMatching.getMatching(); if (me != null && me.size() != 0) matching = me; } 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; }
Example 2
Source File: ForwardedMessageListConsumer.java From RocketMqCurrencyBoot with Apache License 2.0 | 6 votes |
/** * 匹配 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"))) { return equalsbody(matchingMap, MqTags, Mqbody, Topic);// 不需要匹配body } 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; } } }
Example 3
Source File: ForwardedMessageListConsumer.java From RocketMqCurrencyBoot with Apache License 2.0 | 6 votes |
/** * 匹配 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 { // 转发到MQ return sendMq(matchingMap, Mqbody, Topic); } }
Example 4
Source File: ForwardedMessageListConsumer.java From RocketMqCurrencyBoot with Apache License 2.0 | 6 votes |
/** * 将数据发送给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 5
Source File: ConsumableMessageListenerConsumer.java From RocketMqCurrencyBoot with Apache License 2.0 | 5 votes |
@Override public ConsumeConcurrentlyStatus consumeMessage(String strBody, MessageExt msg, ConsumeConcurrentlyContext context) { LOGGER.info("\n 当前线程是" + Thread.currentThread().getId() + " \n 数据是" + strBody); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; }
Example 6
Source File: ExternalCallConcurrentlyStatus.java From RocketMqCurrencyBoot with Apache License 2.0 | 5 votes |
@Override public ConsumeConcurrentlyStatus consumeMessage(String strBody, MessageExt msg, ConsumeConcurrentlyContext context) { if (baseMatching != null) { List<Map<String, String>> me = baseMatching.getMatching(); if (me != null && me.size() != 0) matching = me; } // TODO 待完善 日志系统 最简单的方法是 使用 mongodb 存放日志数据 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, strBody, msg, context); } return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; }
Example 7
Source File: MetaSpout.java From jstorm with Apache License 2.0 | 5 votes |
@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; } }