public AbstractMQProducer(String topic) { super(); producerGroupName = RandomUtil.getStringByUUID(); producerInstanceName = RandomUtil.getStringByUUID(); this.topic = topic; }
public void waitForMessageConsume(int timeoutMills) { TestUtil.waitForMonment(timeoutMills); }
public RMQDelayListner() { msgDelayTimes = DataCollectorManager.getInstance() .fetchDataCollector(RandomUtil.getStringByUUID()); }
public static boolean initTopic(String topic, String nsAddr, String clusterName, int queueNumbers) { long startTime = System.currentTimeMillis(); boolean createResult; while (true) { createResult = MQAdmin.createTopic(nsAddr, clusterName, topic, queueNumbers); if (createResult) { break; } else if (System.currentTimeMillis() - startTime > topicCreateTime) { Assert.fail(String.format("topic[%s] is created failed after:%d ms", topic, System.currentTimeMillis() - startTime)); break; } else { TestUtils.waitForMoment(500); continue; } } return createResult; }
public static String initConsumerGroup(String group) { MQAdmin.createSub(nsAddr, clusterName, group); return group; }
public static String initTopic() { String topic = MQRandomUtils.getRandomTopic(); IntegrationTestBase.initTopic(topic, nsAddr, clusterName); return topic; }
public static String initConsumerGroup() { String group = MQRandomUtils.getRandomConsumerGroup(); return initConsumerGroup(group); }
public AbstractMQProducer(String topic, String originMsgCollector, String msgBodyCollector) { super(originMsgCollector, msgBodyCollector); producerGroupName = RandomUtil.getStringByUUID(); producerInstanceName = RandomUtil.getStringByUUID(); this.topic = topic; }
public void send(long msgNum, int intervalMills) { for (int i = 0; i < msgNum; i++) { this.send(); TestUtil.waitForMonment(intervalMills); } }
private void create() { producer = new DefaultMQProducer(); producer.setProducerGroup(RandomUtil.getStringByUUID()); producer.setInstanceName(RandomUtil.getStringByUUID()); if (nsAddr != null) { producer.setNamesrvAddr(nsAddr); } }
public void waitForResponse(int timeoutMills) { long startTime = System.currentTimeMillis(); while (this.successSendResult.size() != this.msgSize) { if (System.currentTimeMillis() - startTime < timeoutMills) { TestUtil.waitForMonment(100); } else { logger.info("timeout but still not recv all response!"); break; } } }
public Object getMessageByTag(String tag) { Object objMsg = null; if (this instanceof RMQNormalProducer) { org.apache.rocketmq.common.message.Message msg = new org.apache.rocketmq.common.message.Message( topic, (RandomUtil.getStringByUUID() + "." + new Date()).getBytes()); objMsg = msg; if (tag != null) { msg.setTags(tag); } } return objMsg; }
public void send(String tag, int msgSize, int intervalMills) { for (int i = 0; i < msgSize; i++) { Object msg = getMessageByTag(tag); send(msg, null); TestUtil.waitForMonment(intervalMills); } }
public void asyncSend(int msgSize, MessageQueueSelector selector) { this.msgSize = msgSize; for (int i = 0; i < msgSize; i++) { Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes()); this.asyncSend(msg, selector, i); } }
public void sendOneWay(int msgSize) { for (int i = 0; i < msgSize; i++) { Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes()); this.sendOneWay(msg); } }
public void asyncSend(int msgSize) { this.msgSize = msgSize; for (int i = 0; i < msgSize; i++) { Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes()); this.asyncSend(msg); } }
public void sendOneWay(int msgSize, MessageQueue mq) { for (int i = 0; i < msgSize; i++) { Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes()); this.sendOneWay(msg, mq); } }
public void asyncSend(int msgSize, MessageQueue mq) { this.msgSize = msgSize; for (int i = 0; i < msgSize; i++) { Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes()); this.asyncSend(msg, mq); } }
public void sendOneWay(int msgSize, MessageQueueSelector selector) { for (int i = 0; i < msgSize; i++) { Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes()); this.sendOneWay(msg, selector, i); } } }
public void create(boolean useTLS) { consumer = new DefaultMQPushConsumer(consumerGroup); consumer.setInstanceName(RandomUtil.getStringByUUID()); consumer.setNamesrvAddr(nsAddr); try { consumer.subscribe(topic, subExpression); } catch (MQClientException e) { logger.error("consumer subscribe failed!"); e.printStackTrace(); } consumer.setMessageListener(listener); consumer.setUseTLS(useTLS); }