-
Notifications
You must be signed in to change notification settings - Fork 197
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
Limit for inflight messages #167
Conversation
…inflight-messages
@@ -127,7 +128,11 @@ trait ReceiveMessageDirectives { | |||
<RequestId>{EmptyRequestId}</RequestId> | |||
</ResponseMetadata> | |||
</ReceiveMessageResponse> | |||
} | |||
} | |||
case Left(sqsError) => |
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.
isn't there a mechanism which converts all sqs error exceptions (failued futures) into xml?
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.
Yes, there is, but I didn't use it here since the value in the Left is actually elasticMQException.
I renamed the variable to reflect that
@@ -1696,6 +1724,60 @@ class AmazonJavaSdkTestSuite extends FunSuite with Matchers with BeforeAndAfter | |||
} | |||
} | |||
|
|||
test("should hit inflight messages limit") { | |||
import org.elasticmq.actor.reply._ | |||
implicit val timeout = { |
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.
wouldn't it be easier to just send 20001 messages to a FIFO queue?
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.
(no need for extra client, access to the actors, etc.)
if (inflightMessagesRegisty.size >= queueData.inflightMessagesLimit) | ||
Left(new OverLimitError(queueData.name)) | ||
else { | ||
implicit val np = nowProvider |
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.
maybe extract this to a method?
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 did refactor receiving messages to private method
@@ -177,6 +186,7 @@ trait QueueActorMessageOps extends Logging { | |||
messageQueue.byId.get(msgId).foreach { msgData => | |||
if (msgData.deliveryReceipts.lastOption.contains(deliveryReceipt.receipt)) { | |||
// Just removing the msg from the map. The msg will be removed from the queue when trying to receive it. | |||
inflightMessagesRegisty -= msgId |
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.
[typo] Registy. Though maybe simply name it sth like inflightMessageIds
, as that's what this is
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.
Great suggestion! Renamed
|
||
tryReply() | ||
tryReply() | ||
case _ => () |
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.
and what if there are requests waiting for receiving a message, but the limit is hit? Does deleting a message trigger responding to waiting requests as well?
#160