Admiral-Piett / goaws

AWS (SQS/SNS) Clone for Development testing
MIT License
779 stars 144 forks source link

SQS return ApproximateReceiveCount #176

Closed vintuwei closed 5 years ago

vintuwei commented 5 years ago

Receiving messages with the java amazon-sqs-java-messaging-lib throws a NumberFormatException since the response from goaws doesn't include the ApproximateReceiveCount. This should be returned in the "Attributes" field of the message.

Ref: https://docs.aws.amazon.com/cli/latest/reference/sqs/receive-message.html

mwaaas commented 5 years ago

Making request to the actual aws sqs with the following command

aws sqs receive-message --queue-url https://sqs.eu-west-1.amazonaws.com/309952364818/development_xxxxxxx --attribute-names All --message-attribute-names All

You get the following response { "Messages": [ { "MessageId": "33400d8b-a645-4ccf-b0a1-ea7a34efa381", "ReceiptHandle": "xxxxxx", "MD5OfBody": "9d3f5eaac3b1b4dd509f39e71e25f954", "Body": "this is a test of the GoAws Queue messaging", "Attributes": { "SenderId": "xxxxxxx", "ApproximateFirstReceiveTimestamp": "1539688218231", "ApproximateReceiveCount": "4", "SentTimestamp": "1539688218231" }, "MD5OfMessageAttributes": "bf8b36865b2028fcd169fa481bd626a8", "MessageAttributes": { "City": { "StringValue": "Nairobi", "DataType": "String" }, "documentType": { "StringValue": "java.lang.String", "DataType": "String" } } } ] }

But if you do the same to goaws you get the same response format without the Attributes which is being used by amazon sqs jms adapter for spring. Hence it work in Java spring

mwaaas commented 5 years ago

this would fix the issue https://github.com/p4tin/goaws/pull/178