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