com.alibaba.rocketmq.client.log.ClientLogger Java Examples
The following examples show how to use
com.alibaba.rocketmq.client.log.ClientLogger.
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: MQHelper.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel * which model * @param instanceName * which instance * @param consumerGroup * consumer group * @param topic * topic * @param timestamp * time * @throws Exception */ public static void resetOffsetByTimestamp(// final MessageModel messageModel,// final String instanceName,// final String consumerGroup, // final String topic, // final long timestamp) throws Exception { final Logger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example #2
Source File: RocketMQProducer.java From uavstack with Apache License 2.0 | 5 votes |
@Override public void start() { ClientLogger.setLog(new RMQClientLogger()); try { producer.start(); } catch (MQClientException e) { log.err("com.creditease.uav.mq.rocketmq.RocketMQProducer.start", "MQProducer启动失败", e); } }
Example #3
Source File: MQHelper.java From rocketmq with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel * which model * @param instanceName * which instance * @param consumerGroup * consumer group * @param topic * topic * @param timestamp * time * * @throws Exception */ public static void resetOffsetByTimestamp(// final MessageModel messageModel,// final String instanceName,// final String consumerGroup, // final String topic, // final long timestamp) throws Exception { final Logger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }
Example #4
Source File: MQHelper.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
/** * Reset consumer topic offset according to time * * @param messageModel * which model * @param instanceName * which instance * @param consumerGroup * consumer group * @param topic * topic * @param timestamp * time * @throws Exception */ public static void resetOffsetByTimestamp(// final MessageModel messageModel, // final String instanceName, // final String consumerGroup, // final String topic, // final long timestamp) throws Exception { final Logger log = ClientLogger.getLog(); DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup); consumer.setInstanceName(instanceName); consumer.setMessageModel(messageModel); consumer.start(); Set<MessageQueue> mqs = null; try { mqs = consumer.fetchSubscribeMessageQueues(topic); if (mqs != null && !mqs.isEmpty()) { TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs); for (MessageQueue mq : mqsNew) { long offset = consumer.searchOffset(mq, timestamp); if (offset >= 0) { consumer.updateConsumeOffset(mq, offset); log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}", consumerGroup, offset, mq); } } } } catch (Exception e) { log.warn("resetOffsetByTimestamp Exception", e); throw e; } finally { if (mqs != null) { consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs); } consumer.shutdown(); } }