use of com.amazonaws.services.sqs.model.Message in project camel by apache.
the class SqsDoesNotExtendMessageVisibilityTest method defaultsToDisabled.
@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.
// 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 no changeMessageVisibility requests.", this.clientMock.changeMessageVisibilityRequests.size() == 0);
}
use of com.amazonaws.services.sqs.model.Message 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());
}
}
use of com.amazonaws.services.sqs.model.Message in project camel by apache.
the class AmazonSQSClientMock method sendMessage.
@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;
}
use of com.amazonaws.services.sqs.model.Message in project camel by apache.
the class SqsBatchConsumerTest method createRegistry.
@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;
}
use of com.amazonaws.services.sqs.model.Message in project camel by apache.
the class SqsConsumer method createExchanges.
protected Queue<Exchange> createExchanges(List<Message> messages) {
if (LOG.isTraceEnabled()) {
LOG.trace("Received {} messages in this poll", messages.size());
}
Queue<Exchange> answer = new LinkedList<Exchange>();
for (Message message : messages) {
Exchange exchange = getEndpoint().createExchange(message);
answer.add(exchange);
}
return answer;
}
Aggregations