use of com.aliyun.mns.client.CloudAccount in project httpx by servicex-sh.
the class MessagePublishExecutor method sendMnsMessage.
public void sendMnsMessage(URI mnsURI, HttpRequest httpRequest) {
String[] keyIdAndSecret = readAliyunAccessToken(httpRequest);
if (keyIdAndSecret == null) {
System.err.println("Please supply access key Id/Secret in Authorization header as : `Authorization: Basic keyId:secret`");
return;
}
try {
String topic = mnsURI.getPath().substring(1);
final MNSClient mnsClient = new CloudAccount(keyIdAndSecret[0], keyIdAndSecret[1], "https://" + mnsURI.getHost()).getMNSClient();
final CloudQueue queueRef = mnsClient.getQueueRef(topic);
final com.aliyun.mns.model.Message message = queueRef.putMessage(new com.aliyun.mns.model.Message(httpRequest.getBodyBytes()));
System.out.println("Succeeded to send message to " + topic + " with ID: " + message.getMessageId());
} catch (Exception e) {
log.error("HTX-105-500", httpRequest.getRequestTarget().getUri(), e);
}
}
use of com.aliyun.mns.client.CloudAccount in project jeesuite-libs by vakinge.
the class MNSClientInstance method getClient.
public static MNSClient getClient() {
if (client != null)
return client;
synchronized (MNSClientInstance.class) {
if (client != null)
return client;
String accessKeyId = ResourceUtils.getAndValidateProperty("aliyun.mns.accessKeyId");
String accessKeySecret = ResourceUtils.getAndValidateProperty("aliyun.mns.accessKeySecret");
String endpoint = ResourceUtils.getAndValidateProperty("aliyun.mns.endpoint");
CloudAccount account = new CloudAccount(accessKeyId, accessKeySecret, endpoint);
client = account.getMNSClient();
}
return client;
}
use of com.aliyun.mns.client.CloudAccount in project rocketmq-connect by apache.
the class MNSSourceTask method start.
@Override
public void start(SourceTaskContext sourceTaskContext) {
super.start(sourceTaskContext);
try {
CloudAccount cloudAccount = new CloudAccount(accessKeyId, accessKeySecret, accountEndpoint);
mnsClient = cloudAccount.getMNSClient();
cloudQueue = mnsClient.getQueueRef(queueName);
} catch (Exception e) {
log.error("MNSSourceTask | start | error => ", e);
throw new RuntimeException(e);
}
}
use of com.aliyun.mns.client.CloudAccount in project jeesuite-libs by vakinge.
the class MNSClientInstance method getClient.
public static MNSClient getClient() {
if (client != null)
return client;
synchronized (MNSClientInstance.class) {
if (client != null)
return client;
String accessKeyId = ResourceUtils.getAndValidateProperty("aliyun.mns.accessKeyId");
String accessKeySecret = ResourceUtils.getAndValidateProperty("aliyun.mns.accessKeySecret");
String endpoint = ResourceUtils.getAndValidateProperty("aliyun.mns.endpoint");
CloudAccount account = new CloudAccount(accessKeyId, accessKeySecret, endpoint);
client = account.getMNSClient();
}
return client;
}
use of com.aliyun.mns.client.CloudAccount in project httpx by httpx-sh.
the class MessagePublishExecutor method sendMnsMessage.
public void sendMnsMessage(URI mnsURI, HttpRequest httpRequest) {
String[] keyIdAndSecret = readAliyunAccessToken(httpRequest);
if (keyIdAndSecret == null) {
System.err.println("Please supply access key Id/Secret in Authorization header as : `Authorization: Basic keyId:secret`");
return;
}
try {
String topic = mnsURI.getPath().substring(1);
final MNSClient mnsClient = new CloudAccount(keyIdAndSecret[0], keyIdAndSecret[1], "https://" + mnsURI.getHost()).getMNSClient();
final CloudQueue queueRef = mnsClient.getQueueRef(topic);
final com.aliyun.mns.model.Message message = queueRef.putMessage(new com.aliyun.mns.model.Message(httpRequest.getBodyBytes()));
System.out.println("Succeeded to send message to " + topic + " with ID: " + message.getMessageId());
} catch (Exception e) {
log.error("HTX-105-500", httpRequest.getRequestTarget().getUri(), e);
}
}
Aggregations