use of com.aliyun.mns.client.CloudQueue 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.CloudQueue in project xnx3 by xnx3.
the class MNSUtil method deleteQueue.
/**
* 删除队列
* @param queueName
*/
public void deleteQueue(String queueName) {
try {
// Delete Queue
CloudQueue queue = getMNSClient().getQueueRef(queueName);
queue.delete();
} catch (ClientException ce) {
clientException(ce);
} catch (ServiceException se) {
serviceException(se);
} catch (Exception e) {
exception(e);
}
}
use of com.aliyun.mns.client.CloudQueue in project summer-bean by cn-cerc.
the class MailRecord method send.
public boolean send() {
QueueSession sess = (QueueSession) handle.getProperty(QueueSession.sessionId);
CloudQueue queue = sess.openQueue(appQueue.queueSendMail);
return sess.append(queue, this.toString());
}
use of com.aliyun.mns.client.CloudQueue in project jeesuite-libs by vakinge.
the class MNSConsumer method start.
private void start() {
CloudQueue queue = MNSClientInstance.createQueueIfAbsent(queueName);
initTopicHanlders();
fetchExecutor = new StandardThreadExecutor(1, 1, 0, TimeUnit.SECONDS, 1, new StandardThreadFactory("mns-Fetch-Executor"));
int maxThread = ResourceUtils.getInt("aliyun.mns.consumer.processThreads", 50);
semaphore = new Semaphore(maxThread);
defaultProcessExecutor = new StandardThreadExecutor(1, maxThread, 60, TimeUnit.SECONDS, 1, new StandardThreadFactory("mns-defaultProcess-Executor"));
fetchExecutor.submit(new Worker(queue));
logger.info("start work for queue Ok -> queue:{}", queue.getQueueURL());
}
use of com.aliyun.mns.client.CloudQueue in project jeesuite-libs by vakinge.
the class MNSClientInstance method createQueueIfAbsent.
public static CloudQueue createQueueIfAbsent(String queueName) {
QueueMeta queueMeta = new QueueMeta();
queueMeta.setQueueName(queueName);
CloudQueue queue = getClient().getQueueRef(queueName);
if (!queue.isQueueExist()) {
queue.create(queueMeta);
}
return queue;
}
Aggregations