Java Code Examples for com.amazonaws.services.sqs.model.Message#setMessageId()
The following examples show how to use
com.amazonaws.services.sqs.model.Message#setMessageId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SQSSessionCallbackSchedulerTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: TestGetSQS.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testGetMessageNoAutoDelete() { runner.setProperty(GetSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000"); runner.setProperty(GetSQS.AUTO_DELETE, "false"); Message message1 = new Message(); message1.setBody("TestMessage1"); message1.addAttributesEntry("attrib-key-1", "attrib-value-1"); MessageAttributeValue messageAttributeValue = new MessageAttributeValue(); messageAttributeValue.setStringValue("msg-attrib-value-1"); message1.addMessageAttributesEntry("msg-attrib-key-1", messageAttributeValue); message1.setMD5OfBody("test-md5-hash-1"); message1.setMessageId("test-message-id-1"); message1.setReceiptHandle("test-receipt-handle-1"); ReceiveMessageResult receiveMessageResult = new ReceiveMessageResult() .withMessages(message1); Mockito.when(mockSQSClient.receiveMessage(Mockito.any(ReceiveMessageRequest.class))).thenReturn(receiveMessageResult); runner.run(1); ArgumentCaptor<ReceiveMessageRequest> captureRequest = ArgumentCaptor.forClass(ReceiveMessageRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).receiveMessage(captureRequest.capture()); ReceiveMessageRequest request = captureRequest.getValue(); assertEquals("https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000", request.getQueueUrl()); Mockito.verify(mockSQSClient, Mockito.never()).deleteMessageBatch(Mockito.any(DeleteMessageBatchRequest.class)); runner.assertAllFlowFilesTransferred(GetSQS.REL_SUCCESS, 1); List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetSQS.REL_SUCCESS); MockFlowFile ff0 = flowFiles.get(0); ff0.assertAttributeEquals("sqs.attrib-key-1", "attrib-value-1"); ff0.assertAttributeEquals("sqs.msg-attrib-key-1", "msg-attrib-value-1"); ff0.assertAttributeEquals("hash.value", "test-md5-hash-1"); ff0.assertAttributeEquals("hash.algorithm", "md5"); ff0.assertAttributeEquals("sqs.message.id", "test-message-id-1"); ff0.assertAttributeEquals("sqs.receipt.handle", "test-receipt-handle-1"); }
Example 3
Source File: TestGetSQS.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testGetMessageAndAutoDelete() { runner.setProperty(GetSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000"); runner.setProperty(GetSQS.AUTO_DELETE, "true"); Message message1 = new Message(); message1.setBody("TestMessage1"); message1.setMessageId("test-message-id-1"); message1.setReceiptHandle("test-receipt-handle-1"); Message message2 = new Message(); message2.setBody("TestMessage2"); message2.setMessageId("test-message-id-2"); message2.setReceiptHandle("test-receipt-handle-2"); ReceiveMessageResult receiveMessageResult = new ReceiveMessageResult() .withMessages(message1, message2); Mockito.when(mockSQSClient.receiveMessage(Mockito.any(ReceiveMessageRequest.class))).thenReturn(receiveMessageResult); runner.run(1); ArgumentCaptor<ReceiveMessageRequest> captureReceiveRequest = ArgumentCaptor.forClass(ReceiveMessageRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).receiveMessage(captureReceiveRequest.capture()); ReceiveMessageRequest receiveRequest = captureReceiveRequest.getValue(); assertEquals("https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000", receiveRequest.getQueueUrl()); ArgumentCaptor<DeleteMessageBatchRequest> captureDeleteRequest = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).deleteMessageBatch(captureDeleteRequest.capture()); DeleteMessageBatchRequest deleteRequest = captureDeleteRequest.getValue(); assertEquals("https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000", deleteRequest.getQueueUrl()); assertEquals("test-message-id-1", deleteRequest.getEntries().get(0).getId()); assertEquals("test-message-id-2", deleteRequest.getEntries().get(1).getId()); runner.assertAllFlowFilesTransferred(GetSQS.REL_SUCCESS, 2); List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetSQS.REL_SUCCESS); MockFlowFile ff0 = flowFiles.get(0); ff0.assertAttributeEquals("sqs.message.id", "test-message-id-1"); MockFlowFile ff1 = flowFiles.get(1); ff1.assertAttributeEquals("sqs.message.id", "test-message-id-2"); }