All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.envision.energy.demo.SimpleEventSubDemo Maven / Gradle / Ivy

There is a newer version: 3.0.3
Show newest version
package com.envision.energy.demo;

import com.envision.energy.eos.exception.EOSClientException;
import com.envision.energy.eos.exception.SubscribeException;
import com.envision.energy.eos.sdk.*;
import com.envision.eos.event.api.bo.Event;
import com.google.common.collect.Lists;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

/**
 * @author zhensheng.cai
 */
public class SimpleEventSubDemo {

    private static Logger logger = LogManager.getLogger(SimpleAssetSubDemo.class);

    private static String appKey = "xxxxxx";
    private static String host = "xxxxxx";
    private static String appSecret = "xxxxxx";
    private static String customerId = "xxxxxx";

    public static void  startSimpleDemo(){
        EOSClient client;
        try {
            client = new EOSClient(appKey, appSecret, host);

            IEventService service = client.getEventService();
            try {
                service.subscribe(new IEventHandler() {
                    @Override
                    public void eventRead(Event event) {
                        System.out.println(event);
                    }
                }, Lists.newArrayList("xxxxxx"));

            } catch (SubscribeException e) {
                logger.error("subscribe err ", e);
            }
        }
        catch (EOSClientException e ){
            logger.error("init client err ", e);
        }
    }
    public static void main(String[] args) {
        startSimpleDemo();

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy