Search in sources :

Example 1 with OnsTopicListResponse

use of com.aliyun.ons20190214.models.OnsTopicListResponse in project rocketmq-connect by apache.

the class RocketMQSinkConnector method validate.

@Override
public void validate(KeyValue config) {
    if (StringUtils.isBlank(config.getString(RocketMQConstant.ACCESS_KEY_ID)) || StringUtils.isBlank(config.getString(RocketMQConstant.ACCESS_KEY_SECRET)) || StringUtils.isBlank(config.getString(RocketMQConstant.NAMESRV_ADDR)) || StringUtils.isBlank(config.getString(RocketMQConstant.TOPIC))) {
        throw new RuntimeException("rocketmq required parameter is null !");
    }
    try {
        Config onsConfig = new Config().setAccessKeyId(config.getString(RocketMQConstant.ACCESS_KEY_ID)).setAccessKeySecret(config.getString(RocketMQConstant.ACCESS_KEY_SECRET));
        onsConfig.endpoint = OnsUtils.parseEndpoint(config.getString(RocketMQConstant.NAMESRV_ADDR));
        final Client client = new Client(onsConfig);
        OnsTopicListRequest onsTopicListRequest = new OnsTopicListRequest().setTopic(config.getString(RocketMQConstant.TOPIC)).setInstanceId(config.getString(RocketMQConstant.INSTANCE_ID));
        final OnsTopicListResponse onsTopicListResponse = client.onsTopicList(onsTopicListRequest);
        if (onsTopicListResponse.getBody().getData().getPublishInfoDo().isEmpty()) {
            throw new RuntimeException("rocketmq required parameter topic does not exist !");
        }
    } catch (Exception e) {
        log.error("RocketMQSinkTask | validate | error => ", e);
        throw new RuntimeException(e.getMessage());
    }
}
Also used : OnsTopicListResponse(com.aliyun.ons20190214.models.OnsTopicListResponse) Config(com.aliyun.teaopenapi.models.Config) OnsTopicListRequest(com.aliyun.ons20190214.models.OnsTopicListRequest) Client(com.aliyun.ons20190214.Client)

Example 2 with OnsTopicListResponse

use of com.aliyun.ons20190214.models.OnsTopicListResponse in project rocketmq-connect by apache.

the class RocketMQSourceConnector method validate.

@Override
public void validate(KeyValue config) {
    if (StringUtils.isBlank(config.getString(RocketMQConstant.ACCESS_KEY_ID)) || StringUtils.isBlank(config.getString(RocketMQConstant.ACCESS_KEY_SECRET)) || StringUtils.isBlank(config.getString(RocketMQConstant.NAMESRV_ADDR)) || StringUtils.isBlank(config.getString(RocketMQConstant.TOPIC)) || StringUtils.isBlank(config.getString(RocketMQConstant.CONSUMER_GROUP))) {
        throw new RuntimeException("rocketmq required parameter is null !");
    }
    try {
        Config onsConfig = new Config().setAccessKeyId(config.getString(RocketMQConstant.ACCESS_KEY_ID)).setAccessKeySecret(config.getString(RocketMQConstant.ACCESS_KEY_SECRET));
        onsConfig.endpoint = OnsUtils.parseEndpoint(config.getString(RocketMQConstant.NAMESRV_ADDR));
        final Client client = new Client(onsConfig);
        OnsTopicListRequest onsTopicListRequest = new OnsTopicListRequest().setTopic(config.getString(RocketMQConstant.TOPIC)).setInstanceId(config.getString(RocketMQConstant.INSTANCE_ID));
        final OnsTopicListResponse onsTopicListResponse = client.onsTopicList(onsTopicListRequest);
        if (onsTopicListResponse.getBody().getData().getPublishInfoDo().isEmpty()) {
            throw new RuntimeException("rocketmq required parameter topic does not exist !");
        }
        OnsGroupListRequest onsGroupListRequest = new OnsGroupListRequest().setInstanceId(config.getString(RocketMQConstant.INSTANCE_ID)).setGroupId(config.getString(RocketMQConstant.CONSUMER_GROUP));
        final OnsGroupListResponse onsGroupListResponse = client.onsGroupList(onsGroupListRequest);
        if (onsGroupListResponse.getBody().getData().getSubscribeInfoDo().isEmpty()) {
            throw new RuntimeException("rocketmq required parameter consumerGroup does not exist !");
        }
    } catch (Exception e) {
        log.error("RocketMQSinkTask | validate | error => ", e);
        throw new RuntimeException(e.getMessage());
    }
}
Also used : OnsTopicListResponse(com.aliyun.ons20190214.models.OnsTopicListResponse) OnsGroupListRequest(com.aliyun.ons20190214.models.OnsGroupListRequest) Config(com.aliyun.teaopenapi.models.Config) OnsTopicListRequest(com.aliyun.ons20190214.models.OnsTopicListRequest) OnsGroupListResponse(com.aliyun.ons20190214.models.OnsGroupListResponse) Client(com.aliyun.ons20190214.Client)

Aggregations

Client (com.aliyun.ons20190214.Client)2 OnsTopicListRequest (com.aliyun.ons20190214.models.OnsTopicListRequest)2 OnsTopicListResponse (com.aliyun.ons20190214.models.OnsTopicListResponse)2 Config (com.aliyun.teaopenapi.models.Config)2 OnsGroupListRequest (com.aliyun.ons20190214.models.OnsGroupListRequest)1 OnsGroupListResponse (com.aliyun.ons20190214.models.OnsGroupListResponse)1