use of com.amazonaws.services.sqs.model.CreateQueueResult in project camel by apache.
the class AmazonSQSClientMock method createQueue.
@Override
public CreateQueueResult createQueue(CreateQueueRequest createQueueRequest) throws AmazonServiceException, AmazonClientException {
String queueName = "https://queue.amazonaws.com/541925086079/" + createQueueRequest.getQueueName();
queues.put(queueName, createQueueRequest);
CreateQueueResult result = new CreateQueueResult();
result.setQueueUrl(queueName);
return result;
}
use of com.amazonaws.services.sqs.model.CreateQueueResult in project aws-doc-sdk-examples by awsdocs.
the class SendReceiveMessages method main.
public static void main(String[] args) {
final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
try {
CreateQueueResult create_result = sqs.createQueue(QUEUE_NAME);
} catch (AmazonSQSException e) {
if (!e.getErrorCode().equals("QueueAlreadyExists")) {
throw e;
}
}
String queueUrl = sqs.getQueueUrl(QUEUE_NAME).getQueueUrl();
SendMessageRequest send_msg_request = new SendMessageRequest().withQueueUrl(queueUrl).withMessageBody("hello world").withDelaySeconds(5);
sqs.sendMessage(send_msg_request);
// Send multiple messages to the queue
SendMessageBatchRequest send_batch_request = new SendMessageBatchRequest().withQueueUrl(queueUrl).withEntries(new SendMessageBatchRequestEntry("msg_1", "Hello from message 1"), new SendMessageBatchRequestEntry("msg_2", "Hello from message 2").withDelaySeconds(10));
sqs.sendMessageBatch(send_batch_request);
// receive messages from the queue
List<Message> messages = sqs.receiveMessage(queueUrl).getMessages();
// delete messages from the queue
for (Message m : messages) {
sqs.deleteMessage(queueUrl, m.getReceiptHandle());
}
}
use of com.amazonaws.services.sqs.model.CreateQueueResult in project tutorials by eugenp.
the class SpringCloudSQSIntegrationTest method setupAwsResources.
@BeforeClass
public static void setupAwsResources() {
sendQueueName = UUID.randomUUID().toString();
receiveQueueName = SpringCloudSQS.QUEUE_NAME;
AmazonSQS amazonSQS = SpringCloudAwsTestUtil.amazonSQS();
CreateQueueResult receiveQueue = amazonSQS.createQueue(receiveQueueName);
receiveQueueUrl = receiveQueue.getQueueUrl();
CreateQueueResult sendQueue = amazonSQS.createQueue(sendQueueName);
sendQueueURl = sendQueue.getQueueUrl();
}
use of com.amazonaws.services.sqs.model.CreateQueueResult in project java by wavefrontHQ.
the class SQSQueueFactoryImpl method getOrCreateQueue.
private String getOrCreateQueue(String queueName) {
String queueUrl = queues.getOrDefault(queueName, "");
if (StringUtils.isNotBlank(queueUrl))
return queueUrl;
try {
GetQueueUrlResult queueUrlResult = client.getQueueUrl(new GetQueueUrlRequest().withQueueName(queueName));
queueUrl = queueUrlResult.getQueueUrl();
} catch (QueueDoesNotExistException e) {
logger.info("Queue " + queueName + " does not exist...creating for first time");
} catch (AmazonClientException e) {
logger.log(Level.SEVERE, "Unable to lookup queue by name in aws " + queueName, e);
}
try {
if (StringUtils.isBlank(queueUrl)) {
CreateQueueRequest request = new CreateQueueRequest();
request.addAttributesEntry(QueueAttributeName.MessageRetentionPeriod.toString(), "1209600").addAttributesEntry(QueueAttributeName.ReceiveMessageWaitTimeSeconds.toString(), "20").addAttributesEntry(QueueAttributeName.VisibilityTimeout.toString(), "60").setQueueName(queueName);
CreateQueueResult result = client.createQueue(request);
queueUrl = result.getQueueUrl();
queues.put(queueName, queueUrl);
}
} catch (AmazonClientException e) {
logger.log(Level.SEVERE, "Error creating queue in AWS " + queueName, e);
}
return queueUrl;
}
Aggregations