• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DeleteMessageResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.sqs.model.DeleteMessageResult的典型用法代码示例。如果您正苦于以下问题:Java DeleteMessageResult类的具体用法?Java DeleteMessageResult怎么用?Java DeleteMessageResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DeleteMessageResult类属于com.amazonaws.services.sqs.model包,在下文中一共展示了DeleteMessageResult类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: shutdownOfSqsAndS3FactoryCreatedClientsOccursWhenS3DeleteObjectFails

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
@Test
public void shutdownOfSqsAndS3FactoryCreatedClientsOccursWhenS3DeleteObjectFails() {
    AmazonSQSClient sqs = Mockito.mock(AmazonSQSClient.class);
    AmazonS3Client s3 = Mockito.mock(AmazonS3Client.class);
    String s3Id = "123";
    SqsMessage m = new SqsMessage(RECEIPT_HANDLE, new byte[] {}, 1000, Optional.of(s3Id),
            new SqsMessage.Service(Optional.of(() -> s3), () -> sqs, Optional.of(s3), sqs,
                    QUEUE, Optional.of(BUCKET)));
    Mockito.when(sqs.deleteMessage(QUEUE, RECEIPT_HANDLE))
            .thenReturn(new DeleteMessageResult());
    Mockito.doThrow(new RuntimeException()).when(s3).deleteObject(BUCKET, s3Id);
    try {
        m.deleteMessage(Client.FROM_FACTORY);
        Assert.fail();
    } catch (RuntimeException e) {
        // do nothing
    }
    InOrder inorder = Mockito.inOrder(sqs, s3);
    inorder.verify(s3, Mockito.times(1)).deleteObject(BUCKET, s3Id);
    inorder.verify(s3, Mockito.times(1)).shutdown();
    inorder.verify(sqs, Mockito.times(1)).shutdown();
    Mockito.verifyNoMoreInteractions(sqs, s3);
}
 
开发者ID:davidmoten,项目名称:rxjava2-aws,代码行数:24,代码来源:SqsMessageTest.java


示例2: deleteMessageFromFactoryWhenS3FactoryExists

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
@Test
public void deleteMessageFromFactoryWhenS3FactoryExists() {
    AmazonSQSClient sqs = Mockito.mock(AmazonSQSClient.class);
    AmazonS3Client s3 = Mockito.mock(AmazonS3Client.class);
    String s3Id = "123";
    SqsMessage m = new SqsMessage(RECEIPT_HANDLE, new byte[] {}, 1000, Optional.of(s3Id),
            new SqsMessage.Service(Optional.of(() -> s3), () -> sqs, Optional.of(s3), sqs,
                    QUEUE, Optional.of(BUCKET)));
    Mockito.when(sqs.deleteMessage(QUEUE, RECEIPT_HANDLE))
            .thenReturn(new DeleteMessageResult());
    m.deleteMessage(Client.FROM_FACTORY);
    InOrder inorder = Mockito.inOrder(sqs, s3);
    inorder.verify(s3, Mockito.times(1)).deleteObject(BUCKET, s3Id);
    inorder.verify(sqs, Mockito.times(1)).deleteMessage(QUEUE, RECEIPT_HANDLE);
    inorder.verify(s3, Mockito.times(1)).shutdown();
    inorder.verify(sqs, Mockito.times(1)).shutdown();
    Mockito.verifyNoMoreInteractions(sqs, s3);
}
 
开发者ID:davidmoten,项目名称:rxjava-aws,代码行数:19,代码来源:SqsMessageTest.java


示例3: testClientFromFactory

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
@Test
public void testClientFromFactory() {
    AmazonSQSClient sqs = Mockito.mock(AmazonSQSClient.class);
    SqsMessage m = new SqsMessage(RECEIPT_HANDLE, new byte[] {}, 1000, Optional.empty(),
            new SqsMessage.Service(Optional.empty(), () -> sqs, Optional.empty(), sqs, QUEUE,
                    Optional.empty()));
    Mockito.when(sqs.deleteMessage(QUEUE, RECEIPT_HANDLE))
            .thenReturn(new DeleteMessageResult());
    m.deleteMessage(Client.FROM_FACTORY);
    InOrder inorder = Mockito.inOrder(sqs);
    inorder.verify(sqs, Mockito.times(1)).deleteMessage(QUEUE, RECEIPT_HANDLE);
    inorder.verify(sqs, Mockito.times(1)).shutdown();
    Mockito.verifyNoMoreInteractions(sqs);
}
 
开发者ID:davidmoten,项目名称:rxjava2-aws,代码行数:15,代码来源:SqsMessageTest.java


示例4: testClientFromSourceFailsThenFailsOverToFromFactory

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
@Test
public void testClientFromSourceFailsThenFailsOverToFromFactory() {
    AmazonSQSClient sqs = Mockito.mock(AmazonSQSClient.class);
    SqsMessage m = new SqsMessage(RECEIPT_HANDLE, new byte[] {}, 1000, Optional.empty(),
            new SqsMessage.Service(Optional.empty(), () -> sqs, Optional.empty(), sqs, QUEUE,
                    Optional.empty()));
    Mockito.when(sqs.deleteMessage(QUEUE, RECEIPT_HANDLE)).thenThrow(new RuntimeException())
            .thenReturn(new DeleteMessageResult());
    m.deleteMessage();
    InOrder inorder = Mockito.inOrder(sqs);
    inorder.verify(sqs, Mockito.times(2)).deleteMessage(QUEUE, RECEIPT_HANDLE);
    inorder.verify(sqs, Mockito.times(1)).shutdown();
    Mockito.verifyNoMoreInteractions(sqs);
}
 
开发者ID:davidmoten,项目名称:rxjava2-aws,代码行数:15,代码来源:SqsMessageTest.java


示例5: testShouldCommitTheMessageSuccessfully

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
@Test
public void testShouldCommitTheMessageSuccessfully() {
    final SdkHttpMetadata responseMetadata = mock(SdkHttpMetadata.class);
    when(responseMetadata.getHttpStatusCode()).thenReturn(200);

    final DeleteMessageResult deleteMessageResult = new DeleteMessageResult();
    deleteMessageResult.setSdkHttpMetadata(responseMetadata);

    when(amazonSQS.deleteMessage(anyString(), anyString())).thenReturn(deleteMessageResult);

    sqsFailedEventSource.commit(new SQSFailedEvent(new FailedEvent()));

    verify(amazonSQS).deleteMessage(anyString(), anyString());
}
 
开发者ID:zalando-nakadi,项目名称:paradox-nakadi-consumer,代码行数:15,代码来源:SQSFailedEventSourceTest.java


示例6: deleteMessage

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
@Override
public DeleteMessageResult deleteMessage(DeleteMessageRequest deleteMessageRequest) throws AmazonClientException {
    String receiptHandle = deleteMessageRequest.getReceiptHandle();
    if (inFlight.containsKey(receiptHandle)) {
        ScheduledFuture inFlightTask = inFlight.get(receiptHandle);
        inFlightTask.cancel(true);
    }
    return new DeleteMessageResult();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:AmazonSQSClientMock.java


示例7: deleteMessage

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
@Override
public DeleteMessageResult deleteMessage(DeleteMessageRequest deleteMessageRequest) throws AmazonClientException {
    try {
        DirectorySQSQueue queue = getQueueFromUrl(deleteMessageRequest.getQueueUrl(), false);
        queue.delete(deleteMessageRequest.getReceiptHandle());
        return new DeleteMessageResult();
    } catch (IOException e) {
        throw new AmazonServiceException("error deleting message", e);
    }
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:11,代码来源:DirectorySQS.java


示例8: testSendChangeVisibilityReceiveDeleteMessage_shouldSendChangeVisibilityReceiveAndDeleteMessage

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
@Test
public void testSendChangeVisibilityReceiveDeleteMessage_shouldSendChangeVisibilityReceiveAndDeleteMessage() {
  // create queue
  CreateQueueResult createdQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-earl-grey-queue"));
  // send message
  String messageBody = "{\"life-universe-everything\":42}";
  SendMessageResult sendResult = sqs.sendMessage(new SendMessageRequest().withDelaySeconds(0).withMessageBody(messageBody)
      .withMessageGroupId("some-group-id-123").withQueueUrl(createdQueue.getQueueUrl()));
  assertNotNull("message sending returned ok", sendResult);
  assertNotNull("verify body MD5 exists",sendResult.getMD5OfMessageBody());
  assertNotNull("verify message id exists",sendResult.getMessageId());
  // receive message
  ReceiveMessageResult messageResult = sqs.receiveMessage(new ReceiveMessageRequest()
      .withMaxNumberOfMessages(3).withQueueUrl(createdQueue.getQueueUrl()).withVisibilityTimeout(10)
      .withWaitTimeSeconds(0));
  assertNotNull("verify received message returned ok",messageResult);
  assertEquals("verify correct receive count", 1, messageResult.getMessages().size());
  Message firstMessage = messageResult.getMessages().get(0);
  assertEquals("verify correct body returned",messageBody,firstMessage.getBody());
  assertEquals("verify correct message MD5",getAwsMessageMD5(messageBody),firstMessage.getMD5OfBody());
  assertNotNull("verify message id exists",firstMessage.getMessageId());
  assertNotNull("verify receipt handle exists",firstMessage.getReceiptHandle());
  
  // extend visibility timeout
  ChangeMessageVisibilityResult visibilityResult = sqs.changeMessageVisibility(new ChangeMessageVisibilityRequest()
      .withQueueUrl(createdQueue.getQueueUrl()).withReceiptHandle(firstMessage.getReceiptHandle()).withVisibilityTimeout(40));
  assertNotNull("changing visibility returned ok", visibilityResult);
  
  // verify if message is invisible
  ReceiveMessageResult emptyResult = sqs.receiveMessage(new ReceiveMessageRequest()
      .withMaxNumberOfMessages(1).withQueueUrl(createdQueue.getQueueUrl()).withVisibilityTimeout(20)
      .withWaitTimeSeconds(0));
  assertTrue("at visibility timeout the message should not be available.", emptyResult.getMessages().isEmpty());
  
  // delete message from queue
  DeleteMessageResult deleteResult = sqs.deleteMessage(new DeleteMessageRequest()
      .withQueueUrl(createdQueue.getQueueUrl()).withReceiptHandle(firstMessage.getReceiptHandle()));
  assertNotNull("verify deletion returned ok",deleteResult);

  assertTrue("queue must be empty after removal",getQueues().get("tea-earl-grey-queue").getMessageQueue().isEmpty());
  assertTrue("invisibility-queue must be empty after removal",getQueues().get("tea-earl-grey-queue").getInvisibilityQueueFor(firstMessage.getReceiptHandle()).isEmpty());
  
  // cleanup
  getQueues().remove("tea-earl-grey-queue");
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:46,代码来源:MockSqsTest.java


示例9: deleteMessageAsync

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
public Observable<DeleteMessageResult> deleteMessageAsync(DeleteMessageRequest request) {
    return Observable.from(sqsClient.deleteMessageAsync(request));
}
 
开发者ID:gregwhitaker,项目名称:reactive-sqs-client,代码行数:4,代码来源:ReactiveSqsClient.java


示例10: deleteMessage

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
/**
 * <p>
 * Deletes the specified message from the specified queue and deletes the
 * message payload from Amazon S3 when necessary. You specify the message by
 * using the message's <code>receipt handle</code> and not the
 * <code>message ID</code> you received when you sent the message. Even if
 * the message is locked by another reader due to the visibility timeout
 * setting, it is still deleted from the queue. If you leave a message in
 * the queue for longer than the queue's configured retention period, Amazon
 * SQS automatically deletes it.
 * </p>
 * <p>
 * <b>NOTE:</b> The receipt handle is associated with a specific instance of
 * receiving the message. If you receive a message more than once, the
 * receipt handle you get each time you receive the message is different.
 * When you request DeleteMessage, if you don't provide the most recently
 * received receipt handle for the message, the request will still succeed,
 * but the message might not be deleted.
 * </p>
 * <p>
 * <b>IMPORTANT:</b> It is possible you will receive a message even after
 * you have deleted it. This might happen on rare occasions if one of the
 * servers storing a copy of the message is unavailable when you request to
 * delete the message. The copy remains on the server and might be returned
 * to you again on a subsequent receive request. You should create your
 * system to be idempotent so that receiving a particular message more than
 * once is not a problem.
 * </p>
 *
 * @param deleteMessageRequest
 *            Container for the necessary parameters to execute the
 *            DeleteMessage service method on AmazonSQS.
 *
 * @return The response from the DeleteMessage service method, as returned
 *         by AmazonSQS.
 *
 * @throws ReceiptHandleIsInvalidException
 * @throws InvalidIdFormatException
 *
 * @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 DeleteMessageResult deleteMessage(DeleteMessageRequest deleteMessageRequest) {

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

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

	if (!clientConfiguration.isLargePayloadSupportEnabled()) {
		return super.deleteMessage(deleteMessageRequest);
	}

	String receiptHandle = deleteMessageRequest.getReceiptHandle();
	String origReceiptHandle = receiptHandle;
	if (isS3ReceiptHandle(receiptHandle)) {
		deleteMessagePayloadFromS3(receiptHandle);
		origReceiptHandle = getOrigReceiptHandle(receiptHandle);
	}
	deleteMessageRequest.setReceiptHandle(origReceiptHandle);
	return super.deleteMessage(deleteMessageRequest);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-extended-client-lib,代码行数:72,代码来源:AmazonSQSExtendedClient.java


示例11: deleteMessage

import com.amazonaws.services.sqs.model.DeleteMessageResult; //导入依赖的package包/类
/**
    * <p>
    * Deletes the specified message from the specified queue. You specify
    * the message by using the message's <code>receipt handle</code> and not
    * the <code>message ID</code> you received when you sent the message.
    * Even if the message is locked by another reader due to the visibility
    * timeout setting, it is still deleted from the queue. If you leave a
    * message in the queue for longer than the queue's configured retention
    * period, Amazon SQS automatically deletes it.
    * </p>
    * <p>
    * <b>NOTE:</b> The receipt handle is associated with a specific
    * instance of receiving the message. If you receive a message more than
    * once, the receipt handle you get each time you receive the message is
    * different. When you request DeleteMessage, if you don't provide the
    * most recently received receipt handle for the message, the request
    * will still succeed, but the message might not be deleted.
    * </p>
    * <p>
    * <b>IMPORTANT:</b> It is possible you will receive a message even
    * after you have deleted it. This might happen on rare occasions if one
    * of the servers storing a copy of the message is unavailable when you
    * request to delete the message. The copy remains on the server and
    * might be returned to you again on a subsequent receive request. You
    * should create your system to be idempotent so that receiving a
    * particular message more than once is not a problem.
    * </p>
    *
    * @param deleteMessageRequest Container for the necessary parameters to
    *           execute the DeleteMessage service method on AmazonSQS.
    *
    * @return The response from the DeleteMessage service method, as returned
    *         by AmazonSQS.
    * 
    * @throws ReceiptHandleIsInvalidException
    * @throws InvalidIdFormatException
    *
    * @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 DeleteMessageResult deleteMessage(DeleteMessageRequest deleteMessageRequest) {
	return amazonSqsToBeExtended.deleteMessage(deleteMessageRequest);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-extended-client-lib,代码行数:49,代码来源:AmazonSQSExtendedClientBase.java



注:本文中的com.amazonaws.services.sqs.model.DeleteMessageResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IdleHandler类代码示例发布时间:2022-05-22
下一篇:
Java ReducerFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap