in ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleMQConsumer.java [28:44]
public static void main(String[] args) {
Properties consumerProperties = new Properties();
consumerProperties.setProperty(PropertyKeyConst.GROUP_ID, MQConfig.GROUP_ID);
consumerProperties.setProperty(PropertyKeyConst.AccessKey, MQConfig.ACCESS_KEY);
consumerProperties.setProperty(PropertyKeyConst.SecretKey, MQConfig.SECRET_KEY);
consumerProperties.setProperty(PropertyKeyConst.NAMESRV_ADDR, MQConfig.NAMESRV_ADDR);
Consumer consumer = ONSFactory.createConsumer(consumerProperties);
consumer.subscribe(MQConfig.TOPIC, MQConfig.TAG, new MessageListenerImpl());
consumer.start();
System.out.printf("Consumer start success. %n");
try {
Thread.sleep(200000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}