热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.amazonaws.services.sqs.AmazonSQSClient.sendMessage()方法的使用及代码示例

本文整理了Java中com.amazonaws.services.sqs.AmazonSQSClient.sendMessage()方法的一些代码示例,展示了

本文整理了Java中com.amazonaws.services.sqs.AmazonSQSClient.sendMessage()方法的一些代码示例,展示了AmazonSQSClient.sendMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonSQSClient.sendMessage()方法的具体详情如下:
包路径:com.amazonaws.services.sqs.AmazonSQSClient
类名称:AmazonSQSClient
方法名:sendMessage

AmazonSQSClient.sendMessage介绍

[英]Delivers a message to the specified queue.

A message can include only XML, JSON, and unformatted text. The following Unicode characters are allowed:

#x9 | #xA | #xD | #x20 to #xD7FF | #xE000 to #xFFFD | #x10000 to #x10FFFF

Any characters not included in this list will be rejected. For more information, see the W3C specification for characters.
[中]将消息传递到指定队列。
消息只能包含XML、JSON和未格式化文本。允许使用以下Unicode字符:
#x9.[$1$].[$2$].#x20至[$4$].#xE000至[$6$].#x10000#x10FFFF
此列表中未包含的任何字符都将被拒绝。有关更多信息,请参见W3C specification for characters。

代码示例

代码示例来源:origin: aws/aws-sdk-java

@Override
public SendMessageResult sendMessage(String queueUrl, String messageBody) {
return sendMessage(new SendMessageRequest().withQueueUrl(queueUrl).withMessageBody(messageBody));
}

代码示例来源:origin: apache/usergrid

private void sendMessageToLocalRegionSync(final T body) throws IOException {
if ( sqs == null ) {
logger.error( "SQS client is null, perhaps it failed to initialize successfully" );
return;
}
final String stringBody = toString( body );
if (logger.isDebugEnabled()) {
logger.debug(" sendMessageToLocalRegion " + stringBody);
}
String url = getReadQueue().getUrl();
if ( logger.isTraceEnabled() ) {
logger.trace( "Publishing Message...{} to url: {}", stringBody, url );
}
SendMessageRequest messageRequest = new SendMessageRequest(url, stringBody);
try {
SendMessageResult result = sqs.sendMessage(messageRequest);
if (logger.isTraceEnabled()) {
logger.trace("Successfully published... messageID=[{}], arn=[{}]", result.getMessageId(),
url);
}
} catch (Exception e) {
logger.error(FAILED_TO_SEND_MESSAGE, messageRequest.getMessageBody(), url, e);
sendMessageToLocalRegionAsync(body);
}
}

代码示例来源:origin: aws-amplify/aws-sdk-android

sendMessageRequest.setQueueUrl(queueUrl);
sendMessageRequest.setMessageBody(messageBody);
return sendMessage(sendMessageRequest);

代码示例来源:origin: bitsofinfo/s3-bucket-loader

public void sendMessage(String messageBody) {
this.sqsClient.sendMessage(this.tocQueueUrl, messageBody);
}

代码示例来源:origin: bitsofinfo/s3-bucket-loader

public void send(TocInfo fileInfo, MODE mode) throws Exception {
TOCPayload payload = new TOCPayload();
payload.tocInfo = fileInfo;
payload.mode = mode;

// send!
this.sqsClient.sendMessage(this.tocQueueUrl, gson.toJson(payload));
}

代码示例来源:origin: com.netflix.suro/suro-server

@Override
public boolean send(String message) {
boolean sent = false;
try {
for (String queueUrl : queueUrls) {
SendMessageRequest request = new SendMessageRequest()
.withQueueUrl(queueUrl);
if(enableBase64Encoding) {
request = request.withMessageBody(
new String(
Base64.encodeBase64(
message.getBytes(Charsets.UTF_8))));
} else {
request = request.withMessageBody(message);
}
sqsClient.sendMessage(request);
log.info("SQSNotice: " + message + " sent to " + queueUrl);
if (!sent) {
sentMessageCount.incrementAndGet();
sent = true;
}
}
} catch (Exception e) {
log.error("Exception while sending SQS notice: " + e.getMessage(), e);
}
if (!sent) {
lostMessageCount.incrementAndGet();
}
return sent;
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-sqs

@Override
public SendMessageResult sendMessage(String queueUrl, String messageBody) {
return sendMessage(new SendMessageRequest().withQueueUrl(queueUrl).withMessageBody(messageBody));
}

代码示例来源:origin: com.erudika/para

@Override
public void push(String task) {
if (!StringUtils.isBlank(url) && task != null) {
// only allow strings - ie JSON
if (!StringUtils.isBlank(task)) {
// Send a message
try {
SendMessageRequest sendReq = new SendMessageRequest();
sendReq.setQueueUrl(url);
sendReq.setMessageBody(task);
client().sendMessage(sendReq);
} catch (AmazonServiceException ase) {
logException(ase);
} catch (AmazonClientException ace) {
logger.error("Could not reach SQS. {}", ace.toString());
}
}
}
}

代码示例来源:origin: com.sitewhere/sitewhere-aws

/**
* Send an event message to SQS.
*
* @param event
* @throws SiteWhereException
*/
protected void sendSqsMessage(IDeviceEvent event) throws SiteWhereException {
SendMessageRequest message = new SendMessageRequest();
message.setMessageBody(MarshalUtils.marshalJsonAsString(event));
message.setQueueUrl(getQueueUrl());
SendMessageResult result = getSqs().sendMessage(message);
LOGGER.debug("Sent SQS message with id: " + result.getMessageId());
}

代码示例来源:origin: Comcast/cmb

public static String sendMessage(String relativeQueueUrl, String message, Map messageAttributes) throws Exception {
long ts1 = System.currentTimeMillis();
String receiptHandle = null;

if (useInlineApiCalls) {
receiptHandle = CQSAPI.sendMessage(cnsInternal.getUserId(), relativeQueueUrl, message, null, messageAttributes);
} else {
String absoluteQueueUrl = Util.getAbsoluteQueueUrlForRelativeUrl(relativeQueueUrl);
SendMessageRequest sendMessageRequest = new SendMessageRequest(absoluteQueueUrl, message);

if (messageAttributes != null) {
for (String messageAttributeName : messageAttributes.keySet()) {
MessageAttributeValue value = new MessageAttributeValue();
value.setDataType(messageAttributes.get(messageAttributeName).getDataType());
value.setStringValue(messageAttributes.get(messageAttributeName).getStringValue());
sendMessageRequest.addMessageAttributesEntry(messageAttributeName, value);
}
}
SendMessageResult sendMessageResult = sqs.sendMessage(sendMessageRequest);
receiptHandle = sendMessageResult.getMessageId();
}

long ts2 = System.currentTimeMillis();

CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CNSCQSTime, ts2 - ts1);
logger.debug("event=send_message message_id=" + receiptHandle);

return receiptHandle;
}

代码示例来源:origin: com.amazonaws/aws-android-sdk-sqs

sendMessageRequest.setQueueUrl(queueUrl);
sendMessageRequest.setMessageBody(messageBody);
return sendMessage(sendMessageRequest);

代码示例来源:origin: Comcast/cmb

sqs.sendMessage(sendMessageRequest);
logger.debug("event=send_message queue_url= " + queueUrl + " user_id=" + userId);

代码示例来源:origin: sitewhere/sitewhere

/**
* Send an event message to SQS.
*
* @param event
* @throws SiteWhereException
*/
protected void sendSqsMessage(IDeviceEvent event) throws SiteWhereException {
SendMessageRequest message = new SendMessageRequest();
message.setMessageBody(MarshalUtils.marshalJsonAsString(event));
message.setQueueUrl(getQueueUrl());
SendMessageResult result = getSqs().sendMessage(message);
getLogger().debug("Sent SQS message with id: " + result.getMessageId());
}

代码示例来源:origin: Comcast/cmb

sqs.sendMessage(sendMessageRequest);

推荐阅读
author-avatar
Andrew_Chaoyen_liu_328
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有