use of com.aliyun.mns.client.MNSClient 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.MNSClient 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