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

Java SendMessageBatchResult类代码示例

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

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



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

示例1: testSend

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/**
 * Tests the {@link BatchSQSMsgSender#send(org.apache.flume.Channel)} method. Tests the happy path scenario.
 *
 * @throws Exception
 */
@Test
public void testSend() throws Exception {
    BatchSQSMsgSender sqsMsgSender =
        new BatchSQSMsgSender("https://some-fake/url", "us-east-1", "someAwsAccessKey", "someAwsSecretKey", 5, 10);
    AmazonSQS mockSqs = Mockito.mock(AmazonSQS.class);
    when(mockSqs.sendMessageBatch(any(SendMessageBatchRequest.class))).thenReturn(new SendMessageBatchResult());
    sqsMsgSender.setAmazonSQS(mockSqs);

    byte[] mockMsgPayload = {'A', 'b'};
    Event mockEvent = Mockito.mock(Event.class);
    when(mockEvent.getBody()).thenReturn(mockMsgPayload);

    Channel mockChannel = Mockito.mock(Channel.class);
    when(mockChannel.take()).thenReturn(mockEvent);

    sqsMsgSender.send(mockChannel);
}
 
开发者ID:dpandya,项目名称:flume-ng-aws-sqs-sink,代码行数:23,代码来源:BatchSQSMsgSenderTest.java


示例2: mockBatchResult

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
private SendMessageBatchResult mockBatchResult(int batchSize, int expectedSuccessCount) {
    SendMessageBatchResult mockResult = Mockito.mock(SendMessageBatchResult.class);

    List<SendMessageBatchResultEntry> successfulEntries = new ArrayList<SendMessageBatchResultEntry>();
    for (int i = 0; i < expectedSuccessCount; i++) {
        successfulEntries.add(new SendMessageBatchResultEntry().withId(String.valueOf(i + 1)));
    }
    when(mockResult.getSuccessful()).thenReturn(successfulEntries);
    List<BatchResultErrorEntry> failedEntries = new ArrayList<BatchResultErrorEntry>();
    for (int i = expectedSuccessCount; i < batchSize; i++) {
        failedEntries.add(
            new BatchResultErrorEntry().withId(String.valueOf(i + 1)).withCode("401").withSenderFault(true)
                .withMessage("Invalid binary character"));
    }
    when(mockResult.getFailed()).thenReturn(failedEntries);
    return mockResult;
}
 
开发者ID:dpandya,项目名称:flume-ng-aws-sqs-sink,代码行数:18,代码来源:BatchSQSMsgSenderTest.java


示例3: shouldSendBatchesInSizeOfTen

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
@Test
public void shouldSendBatchesInSizeOfTen() throws Exception {
    when(mockAmazonSQS.sendMessageBatch(any(SendMessageBatchRequest.class))).thenReturn(mock(SendMessageBatchResult.class));
    ArgumentCaptor<SendMessageBatchRequest> captor = ArgumentCaptor.forClass(SendMessageBatchRequest.class);

    messagePublisher.postBatch(messageBatch(10), subject);
    verify(mockAmazonSQS, times(1)).sendMessageBatch(captor.capture());
    assertThat(captor.getValue().getEntries()).hasSize(10);

    messagePublisher.postBatch(messageBatch(20), subject);
    verify(mockAmazonSQS, times(3)).sendMessageBatch(any(SendMessageBatchRequest.class));

    messagePublisher.postBatch(messageBatch(11), subject);
    verify(mockAmazonSQS, times(5)).sendMessageBatch(captor.capture());
    assertThat(captor.getValue().getEntries()).hasSize(1);

    messagePublisher.postBatch(messageBatch(9), subject);
    verify(mockAmazonSQS, times(6)).sendMessageBatch(captor.capture());
    assertThat(captor.getValue().getEntries()).hasSize(9);
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:21,代码来源:QueueServiceSenderTest.java


示例4: publishMessages

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
void publishMessages(List<Message> messages) {
	logger.info("Sending {} messages", messages.size());
	SendMessageBatchRequest batch = new SendMessageBatchRequest(queueURL);
	messages.stream().forEach(msg -> {
		SendMessageBatchRequestEntry sendr = new SendMessageBatchRequestEntry(msg.getId(), msg.getPayload());
		batch.getEntries().add(sendr);
	});
	logger.info("sending {}", batch.getEntries().size());
	SendMessageBatchResult result = client.sendMessageBatch(batch);
	logger.info("send result {}", result.getFailed().toString());
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:12,代码来源:SQSObservableQueue.java


示例5: send

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
@Override
public int send(Channel channel) throws EventDeliveryException {
    int eventProcessedCounter = 0;
    // Create batch request
    List<SendMessageBatchRequest> batchRequests = createBatches(channel);

    for (SendMessageBatchRequest batchRequest : batchRequests) {
        // Send batch request
        SendMessageBatchResult result = null;
        try {
            result = this.amazonSQS.sendMessageBatch(batchRequest);
        }
        catch (AmazonServiceException ase) {
            // Throw request reached to SQS but the whole batch was rejected for some reason. Let the whole batch
            // be treated as "failed". Flume will retry the while batch
            throw new EventDeliveryException("Failure sending batch message request to Amazon SQS, " +
                "the request made it to SQS but was rejected for some reason.", ase);
        }
        catch (AmazonClientException ace) {
            throw new EventDeliveryException("Failure sending batch message request to Amazon SQS.", ace);
        }

        // Handle the result of the SQS batch request i.e., log errors, or fail the whole batch by throwing
        // EventDeliveryException in case of errors etc.
        handleResult(batchRequest, result);

        // The code reached here means there is nothing to rollback in this transaction. So increment the
        // eventProcessedCounter by the number of successfully sent messages.
        eventProcessedCounter += result.getSuccessful().size();
    }
    return eventProcessedCounter;
}
 
开发者ID:dpandya,项目名称:flume-ng-aws-sqs-sink,代码行数:33,代码来源:BatchSQSMsgSender.java


示例6: handleResult

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/**
 * Handles SQS send message batch result and throws EventDeliveryException to cause the flume transaction to fail
 * and let flume retry the whole batch in case all the messages in the batch failed to be delivered to SQS.
 * Currently, this method does just logs errors and skips the messages in case some messages from the batched failed
 * to be delivered but some succeeded (i.e., partial batch failure).
 * <p>
 * TODO: Add retry logic instead letting flume drop the failed messages in case of partial batch failure
 *
 * @param batchRequest The SQS SendMessageBatchRequest
 * @param batchResult The SQS SendMessageBatchResult
 *
 * @throws EventDeliveryException In case all the messages in the batch failed to be delivered to SQS
 */
protected void handleResult(SendMessageBatchRequest batchRequest, SendMessageBatchResult batchResult)
    throws EventDeliveryException {

    List<SendMessageBatchRequestEntry> batchRequestEntries = batchRequest.getEntries();
    List<BatchResultErrorEntry> errors = batchResult.getFailed();

    int attemptedCount = batchRequestEntries == null ? 0 : batchRequestEntries.size();
    int errorCount = errors == null ? 0 : errors.size();

    if (errorCount > 0) {
        String errorMessage = buildErrorMessage(batchRequestEntries, errors);

        if (attemptedCount == errorCount) {
            // if it was a non-empty batch and if all the messages in the batch have errors then fail the whole
            // batch and let flume rollback the transaction and retry it
            // Just throw the EventDeliveryException. This will eventually cause the channel's transaction to
            // rollback.
            throw new EventDeliveryException(errorMessage);
        }
        else {
            // TODO: Add retry logic instead letting flume drop the failed messages in case of partial batch failure

            // Just log the error message and let flume drop failed messages in case of partial batch failures
            LOG.error(errorMessage);
        }
    }
}
 
开发者ID:dpandya,项目名称:flume-ng-aws-sqs-sink,代码行数:41,代码来源:BatchSQSMsgSender.java


示例7: testSendPartialBatchFailure

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/**
 * Tests the {@link BatchSQSMsgSender#send(org.apache.flume.Channel)} method. Tests the failure scenario when
 * certain messages in the batch failed to be delivered to SQS.
 * <p>
 * <pre>
 * Expected:
 * - No EventDeliveryException is thrown
 * - The BatchSQSMsgSender returns successfully processed events count
 * </pre>
 *
 * @throws Exception
 */
@Test
public void testSendPartialBatchFailure() throws Exception {
    int batchSize = 5;
    int failedMsgCount = 1;
    int expectedSuccessCount = batchSize - failedMsgCount;

    BatchSQSMsgSender sqsMsgSender =
        new BatchSQSMsgSender("https://some-fake/url", "us-east-1", "someAwsAccessKey", "someAwsSecretKey",
            batchSize, 100);
    AmazonSQS mockSqs = Mockito.mock(AmazonSQS.class);

    SendMessageBatchResult mockResult = mockBatchResult(batchSize, expectedSuccessCount);

    when(mockSqs.sendMessageBatch(any(SendMessageBatchRequest.class))).thenReturn(mockResult);
    sqsMsgSender.setAmazonSQS(mockSqs);

    String msgBody = "Some message payload";
    byte[] mockMsgPayload = msgBody.getBytes();
    Event mockEvent = Mockito.mock(Event.class);
    when(mockEvent.getBody()).thenReturn(mockMsgPayload);

    Channel mockChannel = Mockito.mock(Channel.class);
    when(mockChannel.take()).thenReturn(mockEvent);

    int successCount = sqsMsgSender.send(mockChannel);

    Assert.assertEquals(expectedSuccessCount, successCount);
}
 
开发者ID:dpandya,项目名称:flume-ng-aws-sqs-sink,代码行数:41,代码来源:BatchSQSMsgSenderTest.java


示例8: testSendCompleteBatchFailure

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/**
 * Tests the {@link BatchSQSMsgSender#send(org.apache.flume.Channel)} method. Tests the failure scenario when all
 * the messages in the batch failed to be delivered to SQS.
 * <p>
 * Expected: - EventDeliveryException is thrown - EventDeliveryException also contains the failed messages payload
 * in the exception message
 *
 * @throws Exception
 */
@Test(expected = EventDeliveryException.class)
public void testSendCompleteBatchFailure() throws Exception {
    int batchSize = 5;
    int failedMsgCount = batchSize;
    int expectedSuccessCount = batchSize - failedMsgCount;

    BatchSQSMsgSender sqsMsgSender =
        new BatchSQSMsgSender("https://some-fake/url", "us-east-1", "someAwsAccessKey", "someAwsSecretKey",
            batchSize, 100);
    AmazonSQS mockSqs = Mockito.mock(AmazonSQS.class);

    SendMessageBatchResult mockResult = mockBatchResult(batchSize, expectedSuccessCount);

    when(mockSqs.sendMessageBatch(any(SendMessageBatchRequest.class))).thenReturn(mockResult);
    sqsMsgSender.setAmazonSQS(mockSqs);

    String msgBody = "Some message payload";
    byte[] mockMsgPayload = msgBody.getBytes();
    Event mockEvent = Mockito.mock(Event.class);
    when(mockEvent.getBody()).thenReturn(mockMsgPayload);

    Channel mockChannel = Mockito.mock(Channel.class);
    when(mockChannel.take()).thenReturn(mockEvent);

    try {
        sqsMsgSender.send(mockChannel);
    }
    catch (EventDeliveryException ede) {
        // Make sure that the original payload is also part of the exception error messsage body
        // to get the failed payloads logged along with errors
        Assert.assertTrue(ede.getMessage().contains(msgBody));
        //rethrow as the test is expecting this exception to be thrown
        throw ede;
    }
}
 
开发者ID:dpandya,项目名称:flume-ng-aws-sqs-sink,代码行数:45,代码来源:BatchSQSMsgSenderTest.java


示例9: submitBatches

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/***
 * Submit the batches of messages
 * @param messageBatches
 */
private void submitBatches(
		final Map<String, List<SendMessageBatchRequestEntry>> messageBatches) {
	for(Entry<String, List<SendMessageBatchRequestEntry>> queueBatchEntry : messageBatches.entrySet()){
		final String queueUrl = this.queueAdmin.getQueueUrl(queueBatchEntry.getKey());
		final SendMessageBatchRequest batch = new SendMessageBatchRequest()
		.withQueueUrl(queueUrl)
		.withEntries(queueBatchEntry.getValue());
		final SendMessageBatchResult batchResult = this.sqs.sendMessageBatch(batch);
		this.logFailures(batchResult.getFailed());
	}
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:16,代码来源:SqsProducer.java


示例10: sendMessages

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
@Override
public SendMessageBatchResult sendMessages(SendMessageBatchRequest request,
        ResultCapture<SendMessageBatchResult> extractor) {

    ActionResult result = resource.performAction("SendMessages", request,
            extractor);

    if (result == null) return null;
    return (SendMessageBatchResult) result.getData();
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:QueueImpl.java


示例11: testQueueSubResourceAndAttributes

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/**
 * Tests sending messages using batch operation and retrieve them. Also
 * tests setting the queue attributes and retrieving them.
 */
@Test
@Ignore
public void testQueueSubResourceAndAttributes() throws InterruptedException {

    /**
     * Trying to get the message which is deleted. Here there is no service
     * call made, a new sub resource is created with the given handle. So,
     * this wont be returning null.
     */
    Message message = queue.getMessage("invalid-recepient-handle");
    assertNotNull(message);
    try {
        message.getAttributes();
        fail("An unsupported operation exception must be thrown as load operation is no supported on message attribute");
    } catch (UnsupportedOperationException use) { }

    SendMessageBatchResult sendMessageBatchResult = queue
            .sendMessages(new SendMessageBatchRequest()
                    .withEntries(new SendMessageBatchRequestEntry("msg1",
                            TEST_MESSAGE)));
    SendMessageBatchResultEntry sendMessageBatchResultEntry = sendMessageBatchResult
            .getSuccessful().get(0);
    List<Message> messages = waitForMessagesFromQueue(null);

    assertNotNull(messages);
    assertEquals(1, messages.size());
    message = messages.get(0);
    assertMessage(TEST_MESSAGE, sendMessageBatchResultEntry.getMessageId(),
            sendMessageBatchResultEntry.getMD5OfMessageBody(), message);

    queue.setAttributes(ImmutableMapParameter.of("MaximumMessageSize",
            "2048"));

    assertTrue(queue.getAttributes().containsKey("MaximumMessageSize"));
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:40,代码来源:SQSResourcesIntegrationTest.java


示例12: sendMessageBatch

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
private void sendMessageBatch(Collection<SendMessageBatchRequestEntry> messages) {
    for (Collection<SendMessageBatchRequestEntry> batch : partition(messages, MAX_BATCH_SIZE)) {
        final SendMessageBatchResult sendMessageBatchResult =
            amazonSQS.sendMessageBatch(new SendMessageBatchRequest(queueUrl, new ArrayList<>(batch)));
        final List<BatchResultErrorEntry> failed = sendMessageBatchResult.getFailed();
        if (!failed.isEmpty()) {
            try {
                Set<String> failedMessageIds =
                    failed.stream().map(BatchResultErrorEntry::getId).collect(Collectors.toSet());
                final Map<String, SendMessageBatchRequestEntry> failedMessageIdToMessage =
                    batch.stream().filter(failedMessageIds::contains).collect(Collectors.toMap(
                        SendMessageBatchRequestEntry::getId,
                        Function.identity()
                    ));
                failed.stream().forEach(failMessage -> {
                    final SendMessageBatchRequestEntry failedEntry =
                        failedMessageIdToMessage.get(failMessage.getId());
                    if (failedEntry != null) {
                        final String messageBody = failedEntry.getMessageBody();
                        LOG.error(
                            "Failed to send message, due to {}, message content : {} ",
                            failMessage,
                            messageBody
                        );
                    }
                });
            } catch (Exception e) {
                LOG.error("Failed to log failed to send messages", e);
            }
        }
    }
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:33,代码来源:QueueServiceSender.java


示例13: postBatchShouldSendMessagesWithSNSEnvelope

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
@Test
public void postBatchShouldSendMessagesWithSNSEnvelope() throws Exception {
    // Arrange
    when(mockAmazonSQS.sendMessageBatch(any(SendMessageBatchRequest.class))).thenReturn(mock(SendMessageBatchResult.class));
    ArgumentCaptor<SendMessageBatchRequest> captor = ArgumentCaptor.forClass(SendMessageBatchRequest.class);

    // Act
    messagePublisher.postBatch(
        Arrays.asList(
            new TestMessage("Hello"), new TestMessage("world")
        ), "subject"
    );

    // Assert
    verify(mockAmazonSQS).sendMessageBatch(captor.capture());

    SendMessageBatchRequest sendMessageBatchRequest = captor.getValue();
    assertThat(sendMessageBatchRequest.getQueueUrl()).isEqualTo("queueUrl");

    List<SendMessageBatchRequestEntry> entries = sendMessageBatchRequest.getEntries();
    assertThat(entries.size()).isEqualTo(2);

    ObjectMapper mapper = new ObjectMapper();
    AmazonSNSMessage msg1 = mapper.readValue(entries.get(0).getMessageBody(), AmazonSNSMessage.class);
    assertThat(msg1.getSubject()).isEqualTo("subject");
    assertThat(msg1.getMessage()).isEqualTo("{\"message\":\"Hello\"}");

    AmazonSNSMessage msg2 = mapper.readValue(entries.get(1).getMessageBody(), AmazonSNSMessage.class);
    assertThat(msg2.getSubject()).isEqualTo("subject");
    assertThat(msg2.getMessage()).isEqualTo("{\"message\":\"world\"}");
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:32,代码来源:QueueServiceSenderTest.java


示例14: sendMessageBatch

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
@Override
public SendMessageBatchResult sendMessageBatch(SendMessageBatchRequest sendMessageBatchRequest) throws AmazonClientException {
    DirectorySQSQueue queue = getQueueFromUrl(sendMessageBatchRequest.getQueueUrl(), false);
    //lists for reporting
    List<BatchResultErrorEntry> batchResultErrorEntries = new ArrayList<>();
    List<SendMessageBatchResultEntry> batchResultEntries = new ArrayList<>();
    //attempt to change the visibility on each
    for (SendMessageBatchRequestEntry batchRequestEntry : sendMessageBatchRequest.getEntries()) {
        try {
            final int invisibilityDelay = Objects.firstNonNull(batchRequestEntry.getDelaySeconds(), 0);//0 is amazon spec default
            Message sentMessage = queue.send(batchRequestEntry.getMessageBody(), invisibilityDelay);
            batchResultEntries.add(new SendMessageBatchResultEntry().
                    withId(batchRequestEntry.getId()).
                    withMessageId(sentMessage.getMessageId()).
                    withMD5OfMessageBody(sentMessage.getMD5OfBody()));
        } catch (IOException e) {
            BatchResultErrorEntry batchResultErrorEntry = new BatchResultErrorEntry().
                    withSenderFault(false).
                    withId(batchRequestEntry.getId()).
                    withMessage(e.getMessage());
            batchResultErrorEntries.add(batchResultErrorEntry);
        }
    }
    return new SendMessageBatchResult().
            withFailed(batchResultErrorEntries).
            withSuccessful(batchResultEntries);
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:28,代码来源:DirectorySQS.java


示例15: testBulkSendDelete_shouldWork

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
@Test
public void testBulkSendDelete_shouldWork() {
  // create queue
  CreateQueueResult createdQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-earl-grey-queue"));
  // send batch
  SendMessageBatchRequestEntry firstRequest = new SendMessageBatchRequestEntry().withDelaySeconds(0).withId("one")
      .withMessageGroupId("groupee").withMessageBody("{\"XOXO\":234}");
  SendMessageBatchRequestEntry secondRequest = new SendMessageBatchRequestEntry().withDelaySeconds(0).withId("two")
      .withMessageGroupId("groupee").withMessageBody("{\"Quinoa\":\"Readymade\",\"vegan\":true}");
  SendMessageBatchRequestEntry thirdRequest = new SendMessageBatchRequestEntry().withDelaySeconds(0).withId("three")
      .withMessageGroupId("groupee").withMessageBody("{\"VHS\":\"street art slow-carb\"}");
  // verify send batch result
  SendMessageBatchResult sendResult = sqs.sendMessageBatch(new SendMessageBatchRequest().withQueueUrl(createdQueue.getQueueUrl())
      .withEntries(ImmutableList.of(firstRequest,secondRequest, thirdRequest)));
  assertNotNull("verify that batch send returned ok", sendResult);
  assertTrue("no request failed",sendResult.getFailed().isEmpty());
  assertEquals("verify successfull message count", 3, sendResult.getSuccessful().size());
  SendMessageBatchResultEntry firstResultEntry = sendResult.getSuccessful().stream().filter(msg -> msg.getId().equals("one")).findAny().get();
  assertEquals("verify correct message MD5",getAwsMessageMD5("{\"XOXO\":234}"),firstResultEntry.getMD5OfMessageBody());
  assertNotNull("verify message id exists",firstResultEntry.getMessageId());

  ReceiveMessageResult receivedMessagesResult = sqs.receiveMessage(new ReceiveMessageRequest().withQueueUrl(createdQueue.getQueueUrl()).withMaxNumberOfMessages(4));
  // delete batch
  List<DeleteMessageBatchRequestEntry> deleteRequests = new ArrayList<>();
  deleteRequests.add(new DeleteMessageBatchRequestEntry().withId("one").withReceiptHandle(receivedMessagesResult.getMessages().get(0).getReceiptHandle()));
  deleteRequests.add(new DeleteMessageBatchRequestEntry().withId("two").withReceiptHandle(receivedMessagesResult.getMessages().get(0).getReceiptHandle()));
  deleteRequests.add(new DeleteMessageBatchRequestEntry().withId("three").withReceiptHandle(receivedMessagesResult.getMessages().get(0).getReceiptHandle())); 
  
  DeleteMessageBatchResult deleteBatchResult = sqs.deleteMessageBatch(new DeleteMessageBatchRequest().withQueueUrl(createdQueue.getQueueUrl()).withEntries(deleteRequests));
  
  // verify delete batch result
  assertNotNull("verify that batch delete returned ok", deleteBatchResult);
  assertTrue("no request failed",deleteBatchResult.getFailed().isEmpty());
  assertEquals("verify successfull message count", 3, deleteBatchResult.getSuccessful().size());
  assertTrue("queue must be empty after removal",getQueues().get("tea-earl-grey-queue").getMessageQueue().isEmpty());
  for(Message message : receivedMessagesResult.getMessages()) {
    assertTrue("invisibility-queue must be empty after removal",getQueues().get("tea-earl-grey-queue").getInvisibilityQueueFor(message.getReceiptHandle()).isEmpty());
  }
  
  // cleanup
  getQueues().remove("tea-earl-grey-queue");
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:43,代码来源:MockSqsTest.java


示例16: sendMessageBatchAsync

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


示例17: batchSend

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
public void batchSend(List<SendMessageBatchRequestEntry> entries){

       try {        
       	// Send batch messages
           //System.out.println("\nSending a message to jobQueue.\n");
           
           SendMessageBatchRequest batchRequest = new SendMessageBatchRequest().withQueueUrl(queueUrl);		  	
	  	batchRequest.setEntries(entries);
	
	  	SendMessageBatchResult batchResult = sqs.sendMessageBatch(batchRequest);
	  		
	  	// sendMessageBatch can return successfully, and yet individual batch
	  	// items fail. So, make sure to retry the failed ones.
	  	if (!batchResult.getFailed().isEmpty()) {
	    	//System.out.println("Retry sending failed messages...");
	  		
	  		List<SendMessageBatchRequestEntry> failedEntries = new ArrayList<SendMessageBatchRequestEntry>();
	        Iterator<SendMessageBatchRequestEntry> iter = entries.iterator();
	        
	        while(iter.hasNext()){
	        	if(batchResult.getFailed().contains(iter.next())){
	        		failedEntries.add((SendMessageBatchRequestEntry) iter.next());
	        	}
	        }	
	        
		  	batchRequest.setEntries(failedEntries);
	    	sqs.sendMessageBatch(batchRequest);
	  	}
           
       } catch (AmazonServiceException ase) {
           System.out.println("Caught an AmazonServiceException, which means your request made it " +
                   "to Amazon SQS, but was rejected with an error response for some reason.");
           System.out.println("Error Message:    " + ase.getMessage());
           System.out.println("HTTP Status Code: " + ase.getStatusCode());
           System.out.println("AWS Error Code:   " + ase.getErrorCode());
           System.out.println("Error Type:       " + ase.getErrorType());
           System.out.println("Request ID:       " + ase.getRequestId());
       } catch (AmazonClientException ace) {
           System.out.println("Caught an AmazonClientException, which means the client encountered " +
                   "a serious internal problem while trying to communicate with SQS, such as not " +
                   "being able to access the network.");
           System.out.println("Error Message: " + ace.getMessage());
       }
           
   }
 
开发者ID:cs553-cloud-computing,项目名称:amazon-cloudengine,代码行数:46,代码来源:SQSService.java


示例18: sendMessageBatch

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/**
 * <p>
 * Delivers up to ten messages to the specified queue. This is a batch
 * version of SendMessage. The result of the send action on each message is
 * reported individually in the response. The maximum allowed individual
 * message size is 256 KB (262,144 bytes).
 * </p>
 * <p>
 * The maximum total payload size (i.e., the sum of all a batch's individual
 * message lengths) is also 256 KB (262,144 bytes).
 * </p>
 * <p>
 * If the <code>DelaySeconds</code> parameter is not specified for an entry,
 * the default for the queue is used.
 * </p>
 * <p>
 * <b>IMPORTANT:</b>The following list shows the characters (in Unicode)
 * that are allowed in your message, according to the W3C XML specification.
 * For more information, go to http://www.faqs.org/rfcs/rfc1321.html. If you
 * send any characters that are not included in the list, your request will
 * be rejected. #x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] |
 * [#x10000 to #x10FFFF]
 * </p>
 * <p>
 * <b>IMPORTANT:</b> Because the batch request can result in a combination
 * of successful and unsuccessful actions, you should check for batch errors
 * even when the call returns an HTTP status code of 200.
 * </p>
 * <p>
 * <b>NOTE:</b>Some API actions take lists of parameters. These lists are
 * specified using the param.n notation. Values of n are integers starting
 * from 1. For example, a parameter list with two elements looks like this:
 * </p>
 * <p>
 * <code>&Attribute.1=this</code>
 * </p>
 * <p>
 * <code>&Attribute.2=that</code>
 * </p>
 *
 * @param sendMessageBatchRequest
 *            Container for the necessary parameters to execute the
 *            SendMessageBatch service method on AmazonSQS.
 * 
 * @return The response from the SendMessageBatch service method, as
 *         returned by AmazonSQS.
 * 
 * @throws BatchEntryIdsNotDistinctException
 * @throws TooManyEntriesInBatchRequestException
 * @throws BatchRequestTooLongException
 * @throws UnsupportedOperationException
 * @throws InvalidBatchEntryIdException
 * @throws EmptyBatchRequestException
 *
 * @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 SendMessageBatchResult sendMessageBatch(SendMessageBatchRequest sendMessageBatchRequest)
		throws AmazonServiceException, AmazonClientException {

	return amazonSqsToBeExtended.sendMessageBatch(sendMessageBatchRequest);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-extended-client-lib,代码行数:69,代码来源:AmazonSQSExtendedClientBase.java


示例19: sendMessageBatch

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/**
 * <p>
 * Delivers up to ten messages to the specified queue. This is a batch
 * version of SendMessage. The result of the send action on each message is
 * reported individually in the response. Uploads message payloads to Amazon
 * S3 when necessary.
 * </p>
 * <p>
 * If the <code>DelaySeconds</code> parameter is not specified for an entry,
 * the default for the queue is used.
 * </p>
 * <p>
 * <b>IMPORTANT:</b>The following list shows the characters (in Unicode)
 * that are allowed in your message, according to the W3C XML specification.
 * For more information, go to http://www.faqs.org/rfcs/rfc1321.html. If you
 * send any characters that are not included in the list, your request will
 * be rejected. #x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] |
 * [#x10000 to #x10FFFF]
 * </p>
 * <p>
 * <b>IMPORTANT:</b> Because the batch request can result in a combination
 * of successful and unsuccessful actions, you should check for batch errors
 * even when the call returns an HTTP status code of 200.
 * </p>
 * <p>
 * <b>NOTE:</b>Some API actions take lists of parameters. These lists are
 * specified using the param.n notation. Values of n are integers starting
 * from 1. For example, a parameter list with two elements looks like this:
 * </p>
 * <p>
 * <code>&Attribute.1=this</code>
 * </p>
 * <p>
 * <code>&Attribute.2=that</code>
 * </p>
 *
 * @param queueUrl
 *            The URL of the Amazon SQS queue to take action on.
 * @param entries
 *            A list of <a>SendMessageBatchRequestEntry</a> items.
 *
 * @return The response from the SendMessageBatch service method, as
 *         returned by AmazonSQS.
 *
 * @throws BatchEntryIdsNotDistinctException
 * @throws TooManyEntriesInBatchRequestException
 * @throws BatchRequestTooLongException
 * @throws UnsupportedOperationException
 * @throws InvalidBatchEntryIdException
 * @throws EmptyBatchRequestException
 *
 * @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 SendMessageBatchResult sendMessageBatch(String queueUrl, List<SendMessageBatchRequestEntry> entries) {
	SendMessageBatchRequest sendMessageBatchRequest = new SendMessageBatchRequest(queueUrl, entries);
	return sendMessageBatch(sendMessageBatchRequest);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-extended-client-lib,代码行数:65,代码来源:AmazonSQSExtendedClient.java


示例20: sendMessages

import com.amazonaws.services.sqs.model.SendMessageBatchResult; //导入依赖的package包/类
/**
 * Performs the <code>SendMessages</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>
 *
 * @return The response of the low-level client operation associated with
 *         this resource action.
 * @see SendMessageBatchRequest
 */
SendMessageBatchResult sendMessages(SendMessageBatchRequest request);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:22,代码来源:Queue.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java X509SKIResolver类代码示例发布时间:2022-05-22
下一篇:
Java RefreshAuthorizationPolicyProtocolPB类代码示例发布时间: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