-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix SqsSource attributes adoption from sqs source settings. #1839
Conversation
I guess removing some of the not used/usable |
Thanks for the PR. Since this is breaking user facing API, I'll target this for the upcoming Alpakka 2.0. |
Yes thx, getting the tags helped to fail MiMa. Anything else I can do for now regarding this PR? |
When the |
I have added the required filters to the backwards-exclusion file and the build is green now :) Anything else I can help with? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the problem apply to AWS SNS in a similar way?
@@ -211,24 +211,6 @@ case object MessageDeduplicationId extends AttributeName("MessageDeduplicationId | |||
case object MessageGroupId extends AttributeName("MessageGroupId") | |||
case object SequenceNumber extends AttributeName("SequenceNumber") | |||
|
|||
case object Policy extends AttributeName("Policy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These attributes are available in sqs.model.QueueAttributeName
. Can you find a way to keep these classes as deprecated in Alpakka for the time being? Eg. make them use the the enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be possible to classify these queue-attributes as QueueAttributeName
's (next to the already existing AttributeName
's). They would not be deleted nor deprecated in that case, they 'just' wouldn't be used:
sealed abstract class QueueAttributeName(val name: String)
case object Policy extends QueueAttributeName("Policy")
case object VisibilityTimeout extends QueueAttributeName("VisibilityTimeout")
case object MaximumMessageSize extends QueueAttributeName("MaximumMessageSize")
case object MessageRetentionPeriod extends QueueAttributeName("MessageRetentionPeriod")
case object ApproximateNumberOfMessages extends QueueAttributeName("ApproximateNumberOfMessages")
case object ApproximateNumberOfMessagesNotVisible extends QueueAttributeName("ApproximateNumberOfMessagesNotVisible")
case object CreatedTimestamp extends QueueAttributeName("CreatedTimestamp")
case object LastModifiedTimestamp extends QueueAttributeName("LastModifiedTimestamp")
case object QueueArn extends QueueAttributeName("QueueArn")
case object ApproximateNumberOfMessagesDelayed extends QueueAttributeName("ApproximateNumberOfMessagesDelayed")
case object DelaySeconds extends QueueAttributeName("DelaySeconds")
case object ReceiveMessageWaitTimeSeconds extends QueueAttributeName("ReceiveMessageWaitTimeSeconds")
case object RedrivePolicy extends QueueAttributeName("RedrivePolicy")
case object FifoQueue extends QueueAttributeName("FifoQueue")
case object ContentBasedDeduplication extends QueueAttributeName("ContentBasedDeduplication")
case object KmsMasterKeyId extends QueueAttributeName("KmsMasterKeyId")
case object KmsDataKeyReusePeriodSeconds extends QueueAttributeName("KmsDataKeyReusePeriodSeconds")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not sure if I get your point with "using the enum", but if I get it right it would look like this:
import software.amazon.awssdk.services.sqs.model
sealed abstract class QueueAttributeName(val name: model.QueueAttributeName)
case object Policy extends QueueAttributeName(model.QueueAttributeName.POLICY)
case object VisibilityTimeout extends QueueAttributeName(model.QueueAttributeName.VISIBILITY_TIMEOUT)
case object MaximumMessageSize extends QueueAttributeName(model.QueueAttributeName.MAXIMUM_MESSAGE_SIZE)
case object MessageRetentionPeriod extends QueueAttributeName(model.QueueAttributeName.MESSAGE_RETENTION_PERIOD)
case object ApproximateNumberOfMessages extends QueueAttributeName(model.QueueAttributeName.APPROXIMATE_NUMBER_OF_MESSAGES)
case object ApproximateNumberOfMessagesNotVisible extends QueueAttributeName(model.QueueAttributeName.APPROXIMATE_NUMBER_OF_MESSAGES_NOT_VISIBLE)
case object CreatedTimestamp extends QueueAttributeName(model.QueueAttributeName.CREATED_TIMESTAMP)
case object LastModifiedTimestamp extends QueueAttributeName(model.QueueAttributeName.LAST_MODIFIED_TIMESTAMP)
case object QueueArn extends QueueAttributeName(model.QueueAttributeName.QUEUE_ARN)
case object ApproximateNumberOfMessagesDelayed extends QueueAttributeName(model.QueueAttributeName.APPROXIMATE_NUMBER_OF_MESSAGES_DELAYED)
case object DelaySeconds extends QueueAttributeName(model.QueueAttributeName.DELAY_SECONDS)
case object ReceiveMessageWaitTimeSeconds extends QueueAttributeName(model.QueueAttributeName.RECEIVE_MESSAGE_WAIT_TIME_SECONDS)
case object RedrivePolicy extends QueueAttributeName(model.QueueAttributeName.REDRIVE_POLICY)
case object FifoQueue extends QueueAttributeName(model.QueueAttributeName.FIFO_QUEUE)
case object ContentBasedDeduplication extends QueueAttributeName(model.QueueAttributeName.CONTENT_BASED_DEDUPLICATION)
case object KmsMasterKeyId extends QueueAttributeName(model.QueueAttributeName.KMS_MASTER_KEY_ID)
case object KmsDataKeyReusePeriodSeconds extends QueueAttributeName(model.QueueAttributeName.KMS_DATA_KEY_REUSE_PERIOD_SECONDS)
Using the same approach for the AttributeName
could be a little bit tricky due to aws/aws-sdk-java#2061. There is already an enum sqs.model.MessageSystemAttributeName
modelling the message attributes but this one is currently missing the All
option:
sealed abstract class AttributeName(val name: MessageSystemAttributeName)
case object All extends AttributeName(???)
case object ApproximateFirstReceiveTimestamp extends AttributeName(MessageSystemAttributeName.APPROXIMATE_FIRST_RECEIVE_TIMESTAMP)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about defining them as
sealed abstract class MessageSystemAttributeName(_name: String) extends AttributeName(_name) {
protected def this(msname: model.MessageSystemAttributeName) {
this(msname.toString)
}
}
sealed abstract class QueueAttributeName(qaname: model.QueueAttributeName) extends AttributeName(qaname.toString)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied your suggestion, can you please re-review?
Not that I would be aware of. The SNS has no capabilities to send default attributes (nor the alpakka |
The travis-check If I execute |
I don't know where that came from, some Travis hick-up. I had to remove the Travis cache and now it seems to build as it should. |
I might be misunderstanding something. Are all the |
Yes exactly. The only "valid" |
Ok, sorry, I didn't get that in the first place. Then it makes sense to remove all the attribute classes which can't be used anyway. |
Allright, I just removed the |
Co-Authored-By: Enno <458526+ennru@users.noreply.github.com>
I rebased this branch (to get passed the fatal-warnings check) and fixed the MiMa exclusions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thank you! Sorry again that I didn't get the whole story to start with. |
Thanks @janjaali for the fix 👍, I noticed the same thing in our service. Still looking for a workaround... probably simply have to stick in Upstream issue: aws/aws-sdk-java-v2#1117 (already a few months old 😮) |
Purpose
It seems that the AWS-SDK (not only the one for Java) has an issue by setting the requested attributes in a
ReceiveMessageRequest
against a list ofQueueAttributeNames
which makes no sense: https://github.com/aws/aws-sdk-java/blob/042fa6c1727e52328a9dfd1684f9d46dbb98e39b/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/model/ReceiveMessageRequest.java#L1008.Creating a
ReceiveMessageRequest
inSqsSource
using this method lead to an validation of the provided attributes agains theQueueAttributesNames
which again results in aUNKNOWN_TO_SDK_VERSION
: https://github.com/aws/aws-sdk-java/blob/042fa6c1727e52328a9dfd1684f9d46dbb98e39b/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/model/QueueAttributeName.java#L63This PR will fix the attributes adoption by using the
ReceiveMessageRequest::messageAttributeNames
method without the validation against queue related attribute names.References
References #1838
Changes
Replace attributes adoption in
ReceiveMessageRequest
building phase fromReceiveMessageRequest::attributeNames
method usage toReceiveMessageRequest::attributeNamesWithStrings
.Remove not used
AttributeName
's inSqsSourceSettings
to avoid miss-usage.Add some dedicated tests for the attributes adotion
Background Context
Using alpakka - thx to the awesome alpakka-team - in production code to operate with (among others) SQS hinted me due to a migration to the new alpakka version that we were missing attributes, unfortunately without any warnings.