@Test public void testCreateGetUrlListQueue_shouldCreateReturnUrlAndListQueue() { // create first queue CreateQueueResult createdQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-earl-grey-queue")); assertNotNull("verify that, on creation, queue url was returned",createdQueue.getQueueUrl()); // create other queues CreateQueueResult secondTeaQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-mate-queue")); CreateQueueResult anotherQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("coffee-queue")); // get queue url GetQueueUrlResult queueUrlResult = sqs.getQueueUrl(new GetQueueUrlRequest() .withQueueName("tea-earl-grey-queue").withQueueOwnerAWSAccountId("some owner")); assertNotNull("verify that, on fetch, queue url was returned", queueUrlResult.getQueueUrl()); // get all queues ListQueuesResult allQueues = sqs.listQueues(); assertEquals("verify all queues are returned", 3, allQueues.getQueueUrls().size()); assertTrue("verify that all queues contain first queue", allQueues.getQueueUrls().contains(createdQueue.getQueueUrl())); assertTrue("verify that all queues contain second tea queue", allQueues.getQueueUrls().contains(secondTeaQueue.getQueueUrl())); assertTrue("verify that all queues contain coffee queue", allQueues.getQueueUrls().contains(anotherQueue.getQueueUrl())); // get only queues that start with 'tea' ListQueuesResult teaQueues = sqs.listQueues(new ListQueuesRequest("tea")); assertEquals("verify only tea queues are returned", 2, teaQueues.getQueueUrls().size()); assertTrue("verify that tea queues contain first queue", teaQueues.getQueueUrls().contains(createdQueue.getQueueUrl())); assertTrue("verify that tea queues contain second tea queue", teaQueues.getQueueUrls().contains(secondTeaQueue.getQueueUrl())); assertNotNull("verify that delete queue returned ok", sqs.deleteQueue(new DeleteQueueRequest().withQueueUrl(queueUrlResult.getQueueUrl()))); assertFalse("verify that the queue was removed", sqs.listQueues().getQueueUrls().stream() .anyMatch( queueUrl -> StringUtils.equals(queueUrl,queueUrlResult.getQueueUrl()) )); // cleanup getQueues().remove("tea-earl-grey-queue"); getQueues().remove("tea-mate-queue"); getQueues().remove("coffee-queue"); }
@Override public void removeClusterInfrastructure() { autoScaling.deletePolicy(new DeletePolicyRequest().withAutoScalingGroupName(getAutoScalingGroup().getAutoScalingGroupName()).withPolicyName(SCALE_UP_POLICY)); autoScaling.deletePolicy(new DeletePolicyRequest().withAutoScalingGroupName(getAutoScalingGroup().getAutoScalingGroupName()).withPolicyName(SCALE_DOWN_POLICY)); cloudWatch.deleteAlarms(new DeleteAlarmsRequest().withAlarmNames(ESS_OVERLOAD_ALARM, ESS_IDLE_ALARM)); // CloudWatch metrics are stored for two weeks. Old data will be removed automatically. amazonSQS.deleteQueue(new DeleteQueueRequest().withQueueUrl(ESS_QUEUE_NAME)); cloudFormation.deleteStack(new DeleteStackRequest().withStackName(SystemUtils.getCloudFormationStackName())); }
/** * Deletes an SQS queue on AWS. * @param queueURL URL of the SQS queue */ public static void deleteQueue(String queueURL) { if (!StringUtils.isBlank(queueURL)) { try { getClient().deleteQueue(new DeleteQueueRequest(queueURL)); } catch (AmazonServiceException ase) { logException(ase); } catch (AmazonClientException ace) { logger.error("Could not reach SQS. {0}", ace.toString()); } } }
@Override public DeleteQueueResult deleteQueue(DeleteQueueRequest deleteQueueRequest) throws AmazonClientException { final DirectorySQSQueue queue = getQueueFromUrl(deleteQueueRequest.getQueueUrl(), true); try { Files.delete(queue.getQueuePath()); return new DeleteQueueResult(); } catch (IOException e) { throw new AmazonServiceException("Could not delete queue: " + queue.getQueuePath()); } }
@Test(expectedExceptions = QueueDoesNotExistException.class) public void cannotDeleteNonExistentQueue() throws IOException { _amazonSQS.deleteQueue(new DeleteQueueRequest(new File(TestUtils.createTempDirectory(), someQueueName()).toURI().toString())); }
@Test(expectedExceptions = AmazonServiceException.class) public void deletedQueueNoLongerExists() { final String queueUrl = someNewQueue(); _amazonSQS.deleteQueue(new DeleteQueueRequest(queueUrl)); // this should fail _amazonSQS.receiveMessage(new ReceiveMessageRequest(queueUrl)); }
@Test public void testDeleteQueue_withEmptyRequestParams_shouldWork() { assertNotNull(sqs.deleteQueue(new DeleteQueueRequest())); }
public Observable<DeleteQueueResult> deleteQueueAsync(DeleteQueueRequest request) { return Observable.from(sqsClient.deleteQueueAsync(request)); }
public void deleteQueue () { logger.info("Deleting queue: " + _queueName); _sqs.deleteQueue(new DeleteQueueRequest(_queueURL)); _sqs = null; }
protected void deleteQueue() { getQueue().deleteQueue(new DeleteQueueRequest(getQueueUrl())); // set the url to null so the queue can be re-created queueUrl = null; }
@Override public void delete(DeleteQueueRequest request) { delete(request, null); }
@Override public void delete(DeleteQueueRequest request, ResultCapture<Void> extractor ) { resource.performAction("Delete", request, extractor); }
@Override public void delete(ResultCapture<Void> extractor) { DeleteQueueRequest request = new DeleteQueueRequest(); delete(request, extractor); }
public void deleteQueue(String name){ DeleteQueueRequest request = new DeleteQueueRequest(name); sqsClient.deleteQueue(request); }
/** * <p> * Deletes the queue specified by the <b>queue URL</b> , regardless of * whether the queue is empty. If the specified queue does not exist, Amazon * SQS returns a successful response. * </p> * <p> * <b>IMPORTANT:</b> Use DeleteQueue with care; once you delete your queue, * any messages in the queue are no longer available. * </p> * <p> * When you delete a queue, the deletion process takes up to 60 seconds. * Requests you send involving that queue during the 60 seconds might * succeed. For example, a SendMessage request might succeed, but after the * 60 seconds, the queue and that message you sent no longer exist. Also, * when you delete a queue, you must wait at least 60 seconds before * creating a queue with the same name. * </p> * <p> * We reserve the right to delete queues that have had no activity for more * than 30 days. For more information, see <a href= * "http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSConcepts.html" * > How Amazon SQS Queues Work </a> in the <i>Amazon SQS Developer * Guide</i> . * </p> * * @param deleteQueueRequest * Container for the necessary parameters to execute the * DeleteQueue service method on AmazonSQS. * * * * @throws AmazonClientException * If any internal errors are encountered inside the client * while attempting to make the request or handle the response. * For example if a network connection is not available. * @throws AmazonServiceException * If an error response is returned by AmazonSQS indicating * either a problem with the data in the request, or a server * side issue. */ public DeleteQueueResult deleteQueue(DeleteQueueRequest deleteQueueRequest) throws AmazonServiceException, AmazonClientException { return amazonSqsToBeExtended.deleteQueue(deleteQueueRequest); }
/** * Performs the <code>Delete</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Queue</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>QueueUrl</code></b> * - mapped from the <code>Url</code> identifier. * </li> * </ul> * * <p> * * @see DeleteQueueRequest */ void delete(DeleteQueueRequest request);
/** * Performs the <code>Delete</code> action and use a ResultCapture to * retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Queue</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>QueueUrl</code></b> * - mapped from the <code>Url</code> identifier. * </li> * </ul> * * <p> * * @see DeleteQueueRequest */ void delete(DeleteQueueRequest request, ResultCapture<Void> extractor);