Search in sources :

Example 1 with ChangeMessageVisibilityRequest

use of com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest in project camel by apache.

the class SqsExtendMessageVisibilityTest method longReceiveExtendsMessageVisibility.

@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.
            // 150% of TIMEOUT.
            Thread.sleep(TIMEOUT * 1500L);
        }
    });
    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);
    // Wait for message to arrive.
    assertMockEndpointsSatisfied();
    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());
        // Should be 1.5 x TIMEOUT as takes into account the delay period
        Integer expectedTimeout = new Integer(6);
        assertEquals(expectedTimeout, req.getVisibilityTimeout());
    }
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Message(com.amazonaws.services.sqs.model.Message) ChangeMessageVisibilityRequest(com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest) Test(org.junit.Test)

Aggregations

ChangeMessageVisibilityRequest (com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest)1 Message (com.amazonaws.services.sqs.model.Message)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 Test (org.junit.Test)1