Skip to content

Commit

Permalink
'Version 1.0.2 of the Amazon SQS Extended Client Library for Java'
Browse files Browse the repository at this point in the history
  • Loading branch information
troy-aws committed Apr 25, 2018
1 parent 28afe4d commit df0c625
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For more information on using the amazon-sqs-java-extended-client-lib, see our g
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-sqs-java-extended-client-lib</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<type>jar</type>
</dependency>
```
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.amazonaws</groupId>
<artifactId>amazon-sqs-java-extended-client-lib</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>
<name>Amazon SQS Extended Client Library for Java</name>
<description>An extension to the Amazon SQS client that enables sending and receiving messages up to 2GB via Amazon S3.
Expand Down Expand Up @@ -37,7 +37,7 @@
</developers>

<properties>
<aws-java-sdk.version>1.11.122</aws-java-sdk.version>
<aws-java-sdk.version>1.11.300</aws-java-sdk.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -344,7 +344,9 @@ public ReceiveMessageResult receiveMessage(ReceiveMessageRequest receiveMessageR
return super.receiveMessage(receiveMessageRequest);
}

receiveMessageRequest.getMessageAttributeNames().add(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME);
if (!receiveMessageRequest.getMessageAttributeNames().contains(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME)) {
receiveMessageRequest.getMessageAttributeNames().add(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME);
}

ReceiveMessageResult receiveMessageResult = super.receiveMessage(receiveMessageRequest);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand All @@ -15,9 +15,6 @@

package com.amazon.sqs.javamessaging;

import java.util.List;
import java.util.Map;

import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.AmazonWebServiceRequest;
Expand Down Expand Up @@ -55,6 +52,8 @@
import com.amazonaws.services.sqs.model.InvalidMessageContentsException;
import com.amazonaws.services.sqs.model.ListDeadLetterSourceQueuesRequest;
import com.amazonaws.services.sqs.model.ListDeadLetterSourceQueuesResult;
import com.amazonaws.services.sqs.model.ListQueueTagsRequest;
import com.amazonaws.services.sqs.model.ListQueueTagsResult;
import com.amazonaws.services.sqs.model.ListQueuesRequest;
import com.amazonaws.services.sqs.model.ListQueuesResult;
import com.amazonaws.services.sqs.model.MessageNotInflightException;
Expand All @@ -77,7 +76,14 @@
import com.amazonaws.services.sqs.model.SendMessageResult;
import com.amazonaws.services.sqs.model.SetQueueAttributesRequest;
import com.amazonaws.services.sqs.model.SetQueueAttributesResult;
import com.amazonaws.services.sqs.model.TagQueueRequest;
import com.amazonaws.services.sqs.model.TagQueueResult;
import com.amazonaws.services.sqs.model.TooManyEntriesInBatchRequestException;
import com.amazonaws.services.sqs.model.UntagQueueRequest;
import com.amazonaws.services.sqs.model.UntagQueueResult;

import java.util.List;
import java.util.Map;

abstract class AmazonSQSExtendedClientBase implements AmazonSQS {
AmazonSQS amazonSqsToBeExtended;
Expand Down Expand Up @@ -124,7 +130,7 @@ public SendMessageResult sendMessage(SendMessageRequest sendMessageRequest) {
return amazonSqsToBeExtended.sendMessage(sendMessageRequest);
}

/**
/**
* <p>
* Retrieves one or more messages, with a maximum limit of 10 messages,
* from the specified queue. Long poll support is enabled by using the
Expand Down Expand Up @@ -2015,4 +2021,34 @@ public void shutdown() {
amazonSqsToBeExtended.shutdown();
}

/** {@inheritDoc} */
@Override public ListQueueTagsResult listQueueTags(final ListQueueTagsRequest listQueueTagsRequest) {
return amazonSqsToBeExtended.listQueueTags(listQueueTagsRequest);
}

/** {@inheritDoc} */
@Override public ListQueueTagsResult listQueueTags(final String queueUrl) {
return amazonSqsToBeExtended.listQueueTags(queueUrl);
}

/** {@inheritDoc} */
@Override public TagQueueResult tagQueue(final TagQueueRequest tagQueueRequest) {
return amazonSqsToBeExtended.tagQueue(tagQueueRequest);
}

/** {@inheritDoc} */
@Override public TagQueueResult tagQueue(final String queueUrl, final Map<String, String> tags) {
return amazonSqsToBeExtended.tagQueue(queueUrl, tags);
}

/** {@inheritDoc} */
@Override public UntagQueueResult untagQueue(final UntagQueueRequest untagQueueRequest) {
return amazonSqsToBeExtended.untagQueue(untagQueueRequest);
}

/** {@inheritDoc} */
@Override public UntagQueueResult untagQueue(final String queueUrl, final List<String> tagKeys) {
return amazonSqsToBeExtended.untagQueue(queueUrl, tagKeys);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@
import com.amazonaws.services.s3.AmazonS3;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.annotation.NotThreadSafe;
import com.amazonaws.annotation.NotThreadSafe;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,8 @@
import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.AmazonSQSClient;
import com.amazonaws.services.sqs.model.MessageAttributeValue;
import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
import com.amazonaws.services.sqs.model.ReceiveMessageResult;
import com.amazonaws.services.sqs.model.SendMessageBatchRequest;
import com.amazonaws.services.sqs.model.SendMessageBatchRequestEntry;
import com.amazonaws.services.sqs.model.SendMessageRequest;
Expand Down Expand Up @@ -138,6 +140,24 @@ public void testWhenSendMessageWithSetMessageSizeThresholdThenThresholdIsHonored
verify(mockS3, times(1)).putObject(isA(PutObjectRequest.class));
}

@Test
public void testReceiveMessageMultipleTimesDoesNotAdditionallyAlterReceiveMessageRequest() {
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration()
.withLargePayloadSupportEnabled(mockS3, S3_BUCKET_NAME);
AmazonSQS sqsExtended = spy(new AmazonSQSExtendedClient(mockSqsBackend, extendedClientConfiguration));
when(mockSqsBackend.receiveMessage(isA(ReceiveMessageRequest.class))).thenReturn(new ReceiveMessageResult());

ReceiveMessageRequest messageRequest = new ReceiveMessageRequest();
ReceiveMessageRequest expectedRequest = new ReceiveMessageRequest()
.withMessageAttributeNames(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME);

sqsExtended.receiveMessage(messageRequest);
Assert.assertEquals(expectedRequest, messageRequest);

sqsExtended.receiveMessage(messageRequest);
Assert.assertEquals(expectedRequest, messageRequest);
}

@Test
public void testWhenMessageBatchIsSentThenOnlyMessagesLargerThanThresholdAreStoredInS3() {
// This creates 10 messages, out of which only two are below the threshold (100K and 200K),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down

0 comments on commit df0c625

Please sign in to comment.