Java 类com.amazonaws.services.sqs.model.PurgeQueueRequest 实例源码

项目:unitstack    文件:MockSqsTest.java   
@Test
public void testPurgeQueue_shouldRemoveAll() {
  // create queue
  CreateQueueResult createdQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-earl-grey-queue"));
  // send messages
  String messageBody = "{\"life-universe-everything\":42}";
  sqs.sendMessage(new SendMessageRequest().withDelaySeconds(0).withMessageBody(messageBody)
      .withMessageGroupId("some-group-id-123").withQueueUrl(createdQueue.getQueueUrl()));
  String messageBody2 = "{\"dead-emptyness-nothing\":24}";
  sqs.sendMessage(new SendMessageRequest().withDelaySeconds(0).withMessageBody(messageBody2)
      .withMessageGroupId("some-group-id-123").withQueueUrl(createdQueue.getQueueUrl()));

  // purge queues
  PurgeQueueResult result = sqs.purgeQueue(new PurgeQueueRequest().withQueueUrl(createdQueue.getQueueUrl()));
  assertNotNull("verify that purge queue returned ok", result);

  // verify empty queue
  ReceiveMessageResult messageResult = sqs.receiveMessage(new ReceiveMessageRequest()
      .withMaxNumberOfMessages(9).withQueueUrl(createdQueue.getQueueUrl()).withVisibilityTimeout(10)
      .withWaitTimeSeconds(0));
  assertEquals("verify that queue is empty", 0, messageResult.getMessages().size());

  // cleanup
  getQueues().remove("tea-earl-grey-queue");
}
项目:apex-malhar    文件:SQSTestBase.java   
public void produceMsg(String[] msgs, boolean purgeFirst) throws Exception
{
  CreateQueueResult res = sqs.createQueue(getCurrentQueueName());
  if (purgeFirst) {
    PurgeQueueRequest purgeReq = new PurgeQueueRequest(res.getQueueUrl());
    sqs.purgeQueue(purgeReq);
  }
  for (String text : msgs) {
    sqs.sendMessage(res.getQueueUrl(), text);
  }
}
项目:awslocal    文件:DirectorySQS.java   
@Override
public PurgeQueueResult purgeQueue(PurgeQueueRequest purgeQueueRequest) {
    DirectorySQSQueue queue = getQueueFromUrl(purgeQueueRequest.getQueueUrl(), false);
    try {
        queue.purge();
        return new PurgeQueueResult();
    } catch (IOException e) {
        throw new AmazonServiceException("Could not purge queue: " + queue.getQueuePath());
    }
}
项目:awslocal    文件:TestSQSClient.java   
public void willNotReceiveAfterPurged()
        throws InterruptedException {
    final String queueUrl = someNewQueue();

    for (int i = 0; i < 3; i++) {
        _amazonSQS.sendMessage(new SendMessageRequest(queueUrl, someMessageBody()));
    }

    _amazonSQS.purgeQueue(new PurgeQueueRequest(queueUrl));

    sleep(1);

    verifyReceiveNone(queueUrl);
}
项目:unitstack    文件:MockSqsTest.java   
@Test
public void testPurgeQueue_withEmptyRequestParams_shouldWork() {
  assertNotNull(sqs.purgeQueue(new PurgeQueueRequest()));
}
项目:reactive-sqs-client    文件:ReactiveSqsClient.java   
public Observable<PurgeQueueResult> purgeQueueAsync(PurgeQueueRequest request) {
    return Observable.from(sqsClient.purgeQueueAsync(request));
}
项目:zipkin-aws    文件:AmazonSQSRule.java   
@Override protected void before() {
  if (client != null && queueUrl != null) {
    client.purgeQueue(new PurgeQueueRequest(queueUrl));
  }
}
项目:amazon-sqs-java-extended-client-lib    文件:AmazonSQSExtendedClient.java   
/**
    * <p>
    * Deletes the messages in a queue specified by the <b>queue URL</b> .
    * </p>
    * <p>
    * <b>IMPORTANT:</b>When you use the PurgeQueue API, the deleted messages in
    * the queue cannot be retrieved.
    * </p>
    * <p>
    * <b>IMPORTANT:</b> This does not delete the message payloads from Amazon S3.
    * </p>
    * <p>
    * When you purge a queue, the message deletion process takes up to 60
    * seconds. All messages sent to the queue before calling
    * <code>PurgeQueue</code> will be deleted; messages sent to the queue while
    * it is being purged may be deleted. While the queue is being purged,
    * messages sent to the queue before <code>PurgeQueue</code> was called may
    * be received, but will be deleted within the next minute.
    * </p>
    *
    * @param purgeQueueRequest
    *            Container for the necessary parameters to execute the
    *            PurgeQueue service method on AmazonSQS.
    * @return The response from the PurgeQueue service method, as returned
    *         by 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 PurgeQueueResult purgeQueue(PurgeQueueRequest purgeQueueRequest)
        throws AmazonServiceException, AmazonClientException {
    LOG.warn("Calling purgeQueue deletes SQS messages without deleting their payload from S3.");

    if (purgeQueueRequest == null) {
        String errorMessage = "purgeQueueRequest cannot be null.";
        LOG.error(errorMessage);
        throw new AmazonClientException(errorMessage);
    }

    purgeQueueRequest.getRequestClientOptions().appendUserAgent(SQSExtendedClientConstants.USER_AGENT_HEADER);

    return super.purgeQueue(purgeQueueRequest);
}
项目:amazon-sqs-java-extended-client-lib    文件:AmazonSQSExtendedClientBase.java   
/**
 * <p>
 * Deletes the messages in a queue specified by the <b>queue URL</b> .
 * </p>
 * <p>
 * <b>IMPORTANT:</b>When you use the PurgeQueue API, the deleted messages in
 * the queue cannot be retrieved.
 * </p>
 * <p>
 * When you purge a queue, the message deletion process takes up to 60
 * seconds. All messages sent to the queue before calling
 * <code>PurgeQueue</code> will be deleted; messages sent to the queue while
 * it is being purged may be deleted. While the queue is being purged,
 * messages sent to the queue before <code>PurgeQueue</code> was called may
 * be received, but will be deleted within the next minute.
 * </p>
 *
 * @param purgeQueueRequest
 *            Container for the necessary parameters to execute the
 *            PurgeQueue service method on AmazonSQS.
 * 
 * 
 * @throws PurgeQueueInProgressException
 * @throws QueueDoesNotExistException
 *
 * @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 PurgeQueueResult purgeQueue(PurgeQueueRequest purgeQueueRequest)
        throws AmazonServiceException, AmazonClientException {

    return amazonSqsToBeExtended.purgeQueue(purgeQueueRequest);

}