Package com.aliyun.openservices.ons.example.broadcast

Source Code of com.aliyun.openservices.ons.example.broadcast.ConsumerClient

package com.aliyun.openservices.ons.example.broadcast;

import java.util.Properties;

import com.aliyun.openservices.ons.api.Action;
import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Consumer;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import com.aliyun.openservices.ons.api.ONSFactory;
import com.aliyun.openservices.ons.api.PropertyKeyConst;
import com.aliyun.openservices.ons.api.PropertyValueConst;


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();
    }
}
TOP

Related Classes of com.aliyun.openservices.ons.example.broadcast.ConsumerClient

TOP
Copyright © 2018 www.massapi.com. 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.