Package com.aliyun.openservices.ons.api

Examples of com.aliyun.openservices.ons.api.Consumer


public class ConsumerClient {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put(PropertyKeyConst.ConsumerId, "ConsumerId1");
        properties.put(PropertyKeyConst.MessageModel, PropertyValueConst.BROADCASTING);
        Consumer consumer = ONSFactory.createConsumer(properties);

        consumer.subscribe("TopicTestONS", "*", new MessageListener() {

            @Override
            public Action consume(Message message, ConsumeContext context) {
                System.out.println(message);
                return Action.CommitMessage;
            }
        });

        consumer.start();
    }
View Full Code Here


    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put(PropertyKeyConst.ConsumerId, "CID_001");
        properties.put(PropertyKeyConst.AccessKey, "F0000043D88CB7EF4");
        properties.put(PropertyKeyConst.SecretKey, "F0000043D900F191F");
        Consumer consumer = ONSFactory.createConsumer(properties);
        consumer.subscribe("TopicTestONS", "*", new MessageListener() {

            public Action consume(Message message, ConsumeContext context) {
                System.out.println("Receive: " + message);
                return Action.CommitMessage;
            }
        });

        consumer.start();

        System.out.println("Consumer Started");
    }
View Full Code Here

public class ConsumerClient {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put(PropertyKeyConst.ConsumerId, "ConsumerId1");
        properties.put(PropertyKeyConst.MessageModel, PropertyValueConst.Broadcasting);
        Consumer consumer = ONSFactory.createConsumer(properties);

        consumer.subscribe("TopicTestONS", "*", new MessageListener() {

            @Override
            public Action consume(Message message, ConsumeContext context) {
                System.out.println(message);
                return Action.CommitMessage;
            }
        });

        consumer.start();
    }
View Full Code Here

    public static void main(String[] args) {
        Properties properties = new Properties();
        // ProducerId,代表一类Consumer,请向ONS运维人员申请
        properties.put(PropertyKeyConst.ConsumerId, "jiangjinrong");
        Consumer consumer = ONSFactory.createConsumer(properties);
        consumer.subscribe("TopicTestONS", "*", new MessageListener() {

            @Override
            public Action consume(Message message, ConsumeContext context) {
                System.out.println("Receive: " + message);
                return Action.CommitMessage;
            }
        });

        consumer.start();
    }
View Full Code Here

TOP

Related Classes of com.aliyun.openservices.ons.api.Consumer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.