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

com.aliyun.openservices.ons.api.exactlyonce.ExactlyOnceConsumerWrapper Maven / Gradle / Ivy

There is a newer version: 1.9.4.Final
Show newest version
package com.aliyun.openservices.ons.api.exactlyonce;

import java.util.Properties;

import com.aliyun.openservices.ons.api.MessageListener;
import com.aliyun.openservices.ons.api.MessageSelector;
import com.aliyun.openservices.ons.api.PropertyKeyConst;

/**
 * @author gongshi
 */
public class ExactlyOnceConsumerWrapper implements ExactlyOnceConsumer {

    private ExactlyOnceConsumerImpl exactlyOnceConsumer;

    public ExactlyOnceConsumerWrapper(String consumerId, String accessKey, String secretKey, String onsAddr, String exactlyOnce) {
        Properties properties = new Properties();
        properties.setProperty(PropertyKeyConst.ConsumerId, consumerId);
        properties.setProperty(PropertyKeyConst.AccessKey, accessKey);
        properties.setProperty(PropertyKeyConst.SecretKey, secretKey);
        properties.setProperty(PropertyKeyConst.ONSAddr, onsAddr);
        properties.setProperty(PropertyKeyConst.EXACTLYONCE_DELIVERY, exactlyOnce);
        this.exactlyOnceConsumer = new ExactlyOnceConsumerImpl(properties);
    }

    @Override
    public boolean isStarted() {
        return exactlyOnceConsumer.isStarted();
    }

    @Override
    public boolean isClosed() {
        return exactlyOnceConsumer.isClosed();
    }

    @Override
    public void start() {
        exactlyOnceConsumer.start();
    }

    @Override
    public void updateCredential(Properties credentialProperties) {
        exactlyOnceConsumer.updateCredential(credentialProperties);
    }

    @Override
    public void shutdown() {
        exactlyOnceConsumer.shutdown();
    }

    @Override
    public void subscribe(String topic, String subExpression, MessageListener listener) {
        exactlyOnceConsumer.subscribe(topic, subExpression, listener);
    }

    @Override
    public void subscribe(String topic, MessageSelector selector, MessageListener listener) {
        exactlyOnceConsumer.subscribe(topic, selector, listener);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy