当前位置: 首页>>代码示例>>Java>>正文


Java Message.setReceiptHandle方法代码示例

本文整理汇总了Java中com.amazonaws.services.sqs.model.Message.setReceiptHandle方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setReceiptHandle方法的具体用法?Java Message.setReceiptHandle怎么用?Java Message.setReceiptHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.sqs.model.Message的用法示例。


在下文中一共展示了Message.setReceiptHandle方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: defaultsToDisabled

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Test
public void defaultsToDisabled() throws Exception {
    this.mock.expectedMessageCount(1);
    this.mock.whenAnyExchangeReceived(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            // Simulate message that takes a while to receive.
            Thread.sleep(TIMEOUT * 1500L); // 150% of TIMEOUT.
        }
    });

    Message message = new Message();
    message.setBody("Message 1");
    message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee");
    message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
    message.setReceiptHandle(RECEIPT_HANDLE);
    this.clientMock.messages.add(message);

    assertMockEndpointsSatisfied(); // Wait for message to arrive.
    assertTrue("Expected no changeMessageVisibility requests.", this.clientMock.changeMessageVisibilityRequests.size() == 0);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:SqsDoesNotExtendMessageVisibilityTest.java

示例2: createRegistry

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    
    AmazonSQSClientMock clientMock = new AmazonSQSClientMock();
    // add 6 messages, one more we will poll
    for (int counter = 0; counter < 6; counter++) {
        Message message = new Message();
        message.setBody("Message " + counter);
        message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee");
        message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
        message.setReceiptHandle("0NNAq8PwvXsyZkR6yu4nQ07FGxNmOBWi5");
        
        clientMock.messages.add(message);
    }
    
    registry.bind("amazonSQSClient", clientMock);
    
    return registry;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:SqsBatchConsumerTest.java

示例3: sendMessage

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Override
public SendMessageResult sendMessage(SendMessageRequest sendMessageRequest) throws AmazonServiceException, AmazonClientException {
    Message message = new Message();
    message.setBody(sendMessageRequest.getMessageBody());
    message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee");
    message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
    message.setReceiptHandle("0NNAq8PwvXsyZkR6yu4nQ07FGxNmOBWi5zC9+4QMqJZ0DJ3gVOmjI2Gh/oFnb0IeJqy5Zc8kH4JX7GVpfjcEDjaAPSeOkXQZRcaBqt"
            + "4lOtyfj0kcclVV/zS7aenhfhX5Ixfgz/rHhsJwtCPPvTAdgQFGYrqaHly+etJiawiNPVc=");
 
    synchronized (messages) {
        messages.add(message);
    }
    
    SendMessageResult result = new SendMessageResult();
    result.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
    result.setMD5OfMessageBody("6a1559560f67c5e7a7d5d838bf0272ee");
    return result;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:AmazonSQSClientMock.java

示例4: createFifoMessageManager

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
private SQSMessageConsumerPrefetch.MessageManager createFifoMessageManager(String queueUrl, String groupId, String messageId, String receiptHandle) throws JMSException {
    Message message = new Message();
    message.setBody("body");
    message.setMessageId(messageId);
    message.setReceiptHandle(receiptHandle);
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put(SQSMessagingClientConstants.SEQUENCE_NUMBER, "728374687246872364");
    attributes.put(SQSMessagingClientConstants.MESSAGE_DEDUPLICATION_ID, messageId);
    attributes.put(SQSMessagingClientConstants.MESSAGE_GROUP_ID, groupId);
    attributes.put(SQSMessagingClientConstants.APPROXIMATE_RECEIVE_COUNT, "0");
    message.setAttributes(attributes);
    SQSMessage sqsMessage = new SQSTextMessage(acknowledger, queueUrl, message);
    PrefetchManager prefetchManager = mock(PrefetchManager.class);
    when(prefetchManager.getMessageConsumer())
        .thenReturn(consumer);
    SQSMessageConsumerPrefetch.MessageManager msgManager = new SQSMessageConsumerPrefetch.MessageManager(prefetchManager, sqsMessage);
    return msgManager;
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:19,代码来源:SQSSessionCallbackSchedulerTest.java

示例5: testConvertMessageToEvent

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Test
public void testConvertMessageToEvent() {
    Message message = new Message();
    message.setBody("{\n" +
            "  \"Type\" : \"Notification\",\n" +
            "  \"MessageId\" : \"942c624a-5f4f-5fe4-a2d7-28e60ff48e15\",\n" +
            "  \"TopicArn\" : \"t\",\n" +
            "  \"Subject\" : \"Operation\",\n" +
            "  \"Message\" : \"{\\\"operation\\\":\\\"CREATE\\\",\\\"file\\\":\\\"f4\\\",\\\"originator\\\":\\\"me\\\"}\",\n" +
            "  \"Timestamp\" : \"2013-09-12T23:30:03.434Z\",\n" +
            "  \"SignatureVersion\" : \"1\",\n" +
            "  \"Signature\" : \"n4tdSNZBDlaOgCS2ILxbhCGq3Cl/5LlG2SAh1OKUbat3qWzgtlD5PvgjJUq/heCb5Eo0KnnDYAJbeuiw7X9HmotCtq50OiqCtz6uq6EuApy1LhiBzOhyC5S4yarmQqGV0PBZCGLrvPn/So1HiVsFoBujJZNQuw0ysQQ/ILi6TFA=\",\n" +
            "  \"SigningCertURL\" : \"cert\",\n" +
            "  \"UnsubscribeURL\" : \"foo\"\n" +
            "}");
    message.setReceiptHandle("receiptHandle");
    message.setMessageId("messageId");



    Event event = SQSUtils.convertMessageToEvent(baseDir, message);
    assertEquals("operation is incorrect", FileOperation.CREATE, event.getOperation());
    assertEquals("originator is correct", "me", event.getOriginator());
    assertEquals("file path is correct", "/foo/bar/f4", event.getFile().toPath().toString());
    assertEquals("isDirectory is correct", false, event.isDirectory());
}
 
开发者ID:sharathprabhal,项目名称:NBS3Sync,代码行数:27,代码来源:TestSQSUtils.java

示例6: testConvertMessageToEventIsDirPositive

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Test
public void testConvertMessageToEventIsDirPositive() {
    Message message = new Message();
    message.setBody("{\n" +
            "  \"Type\" : \"Notification\",\n" +
            "  \"MessageId\" : \"942c624a-5f4f-5fe4-a2d7-28e60ff48e15\",\n" +
            "  \"TopicArn\" : \"t\",\n" +
            "  \"Subject\" : \"Operation\",\n" +
            "  \"Message\" : \"{\\\"operation\\\":\\\"CREATE\\\",\\\"file\\\":\\\"dir/\\\",\\\"originator\\\":\\\"me\\\"}\",\n" +
            "  \"Timestamp\" : \"2013-09-12T23:30:03.434Z\",\n" +
            "  \"SignatureVersion\" : \"1\",\n" +
            "  \"Signature\" : \"sig/sig=\",\n" +
            "  \"SigningCertURL\" : \"cert\",\n" +
            "  \"UnsubscribeURL\" : \"foo\"\n" +
            "}");
    message.setReceiptHandle("receiptHandle");
    message.setMessageId("messageId");

    Event event = SQSUtils.convertMessageToEvent(baseDir, message);
    assertEquals("operation is incorrect", FileOperation.CREATE, event.getOperation());
    assertEquals("originator is correct", "me", event.getOriginator());
    assertEquals("file path is correct", "/foo/bar/dir", event.getFile().toPath().toString());
    assertEquals("isDirectory is correct", true, event.isDirectory());
}
 
开发者ID:sharathprabhal,项目名称:NBS3Sync,代码行数:25,代码来源:TestSQSUtils.java

示例7: testShouldFetchFailedEventFromSQS

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Test
public void testShouldFetchFailedEventFromSQS() throws JsonProcessingException {

    final FailedEvent failedEvent = new FailedEvent();
    failedEvent.setRawEvent(randomAlphabetic(10));
    failedEvent.setOffset(randomAlphabetic(10));
    failedEvent.setConsumerName(randomAlphabetic(10));
    failedEvent.setFailedTimeInMilliSeconds(nextLong(1, 10));
    failedEvent.setEventType(new EventType(randomAlphabetic(10)));
    failedEvent.setPartition(randomAlphabetic(10));
    failedEvent.setStackTrace(randomAlphabetic(10));

    final Message message = new Message();
    message.setMessageId(randomAlphabetic(10));
    message.setReceiptHandle(randomAlphabetic(10));
    message.setBody(objectMapper.writeValueAsString(failedEvent));

    final ReceiveMessageResult receiveMessageResult = new ReceiveMessageResult();
    receiveMessageResult.setMessages(Collections.singleton(message));

    when(amazonSQS.receiveMessage(anyString())).thenReturn(receiveMessageResult);

    final Optional<SQSFailedEvent> sqsFailedEventOptional = sqsFailedEventSource.getFailedEvent();
    assertThat(sqsFailedEventOptional).isPresent();

    final SQSFailedEvent sqsFailedEvent = sqsFailedEventOptional.get();
    assertThat(sqsFailedEvent.getRawEvent()).isEqualTo(failedEvent.getRawEvent());
    assertThat(sqsFailedEvent.getReceiptHandle()).isEqualTo(message.getReceiptHandle());
    assertThat(sqsFailedEvent.getConsumerName()).isEqualTo(failedEvent.getConsumerName());
    assertThat(sqsFailedEvent.getEventType()).isEqualTo(failedEvent.getEventType());
    assertThat(sqsFailedEvent.getId()).isEqualTo(message.getMessageId());
    assertThat(sqsFailedEvent.getOffset()).isEqualTo(failedEvent.getOffset());
    assertThat(sqsFailedEvent.getPartition()).isEqualTo(failedEvent.getPartition());
    assertThat(sqsFailedEvent.getStackTrace()).isEqualTo(failedEvent.getStackTrace());
    assertThat(sqsFailedEvent.getFailedTimeInMilliSeconds()).isEqualTo(failedEvent.getFailedTimeInMilliSeconds());
}
 
开发者ID:zalando-nakadi,项目名称:paradox-nakadi-consumer,代码行数:37,代码来源:SQSFailedEventSourceTest.java

示例8: longReceiveExtendsMessageVisibility

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Test
public void longReceiveExtendsMessageVisibility() throws Exception {
    this.mock.expectedMessageCount(1);
    this.mock.whenAnyExchangeReceived(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            // Simulate message that takes a while to receive.
            Thread.sleep(TIMEOUT * 1500L); // 150% of TIMEOUT.
        }
    });

    Message message = new Message();
    message.setBody("Message 1");
    message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee");
    message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
    message.setReceiptHandle(RECEIPT_HANDLE);
    this.clientMock.messages.add(message);

    assertMockEndpointsSatisfied(); // Wait for message to arrive.

    assertTrue("Expected at least one changeMessageVisibility request.", this.clientMock.changeMessageVisibilityRequests.size() >= 1);
    for (ChangeMessageVisibilityRequest req : this.clientMock.changeMessageVisibilityRequests) {
        assertEquals("https://queue.amazonaws.com/541925086079/MyQueue", req.getQueueUrl());
        assertEquals(RECEIPT_HANDLE, req.getReceiptHandle());
        Integer expectedTimeout = new Integer(6); // Should be 1.5 x TIMEOUT as takes into account the delay period
        assertEquals(expectedTimeout, req.getVisibilityTimeout());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:29,代码来源:SqsExtendMessageVisibilityTest.java

示例9: populateMessages

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
private void populateMessages(AmazonSQSClientMock clientMock) {
    Message message = new Message();
    message.setBody("Message: hello, world!");
    message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee");
    message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
    message.setReceiptHandle("0NNAq8PwvXsyZkR6yu4nQ07FGxNmOBWi5");

    clientMock.messages.add(message);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:SqsFilterMessagesWithNoDeleteTest.java

示例10: createDummyMessages

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
private void createDummyMessages(AmazonSQSClientMock client, int numMessages) {
    for (int counter = 0; counter < numMessages; counter++) {
        Message message = new Message();
        message.setBody("Message " + counter);
        message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee");
        message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
        message.setReceiptHandle("0NNAq8PwvXsyZkR6yu4nQ07FGxNmOBWi5");
        client.messages.add(message);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:SqsConcurrentConsumerTest.java

示例11: testDeleteMessage

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Test
public void testDeleteMessage() throws Exception {
    final Message message = new Message();
    message.setReceiptHandle("myReceipt");
    final boolean actual = iterator.deleteMessage(message);
    verify(mockSQS).deleteMessage(QUEUE_URL, "myReceipt");
    assertThat(actual).isTrue();
}
 
开发者ID:smoketurner,项目名称:pipeline,代码行数:9,代码来源:AmazonSQSIteratorTest.java

示例12: testDeleteMessageException

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Test
public void testDeleteMessageException() throws Exception {
    doThrow(new AmazonServiceException("error")).when(mockSQS)
            .deleteMessage(QUEUE_URL, "myReceipt");

    final Message message = new Message();
    message.setReceiptHandle("myReceipt");

    final boolean actual = iterator.deleteMessage(message);
    verify(mockSQS).deleteMessage(QUEUE_URL, "myReceipt");
    assertThat(actual).isFalse();
}
 
开发者ID:smoketurner,项目名称:pipeline,代码行数:13,代码来源:AmazonSQSIteratorTest.java

示例13: createMessage

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
private Message createMessage(String messageId) {
    Message msg = new Message();
    msg.setMessageId(messageId);
    msg.setReceiptHandle(messageId);
    return msg;
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:7,代码来源:QueueProcessorTest.java


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