Skip to content

Commit

Permalink
Merge #24
Browse files Browse the repository at this point in the history
24: Add MessageId to message object as id r=mattBrzezinski a=kevin-yen

*Background*

I have a use case where I need the message ID of a particular message. This PR adds MessageId to the list of fields returned by the message object

*Changes*
* Add MessageId to the object returned by `sqs_receive_message` as the field `id`

Co-authored-by: Kevin Yen <[email protected]>
  • Loading branch information
bors[bot] and kevin-yen authored Jun 23, 2020
2 parents 7cd6673 + 16339dc commit eea6d03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/AWSSQS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ end
"""
sqs_receive_message(::AWSQueue)
Returns a `Dict` containing `:message` and `:handle`
Returns a `Dict` containing `:message`, `:id` and `:handle`
or `nothing` if the queue is empty.
```
Expand All @@ -212,11 +212,12 @@ function sqs_receive_message(queue::AWSQueue)
end

handle = r[1]["ReceiptHandle"]
id = r[1]["MessageId"]
message = r[1]["Body"]
md5 = r[1]["MD5OfBody"]

@assert md5 == bytes2hex(digest(MD_MD5, message))
@SymDict(message, handle)
@SymDict(message, id, handle)
end


Expand Down
5 changes: 4 additions & 1 deletion test/queue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ end
sqs_send_message(queue, "Hello!", options...)
message = sqs_receive_message(queue)

@test haskey(message, :id) && !isempty(message[:id])
@test message[:message] == "Hello!"
end

Expand Down Expand Up @@ -52,6 +53,7 @@ end
sqs_send_message(queue, "Hello!")
message = sqs_receive_message(queue)

@test haskey(message, :id) && !isempty(message[:id])
@test message[:message] == "Hello!"
end

Expand All @@ -66,6 +68,7 @@ end
@test message_count == num_messages

while (m=sqs_receive_message(queue)) != nothing
@test haskey(m, :id) && !isempty(m[:id])
@test m[:message] == "test message"
end
end
Expand All @@ -87,4 +90,4 @@ end
end
end

cleanup_queues()
cleanup_queues()

0 comments on commit eea6d03

Please sign in to comment.