本文整理匯總了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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();
}
示例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;
}