Skip to content
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

Closed
wants to merge 15 commits into from
Closed

Conversation

rwalerow
Copy link

@rwalerow rwalerow requested a review from adamw February 21, 2019 12:19
@rwalerow rwalerow changed the title Limit for inflight messages #160 Limit for inflight messages Feb 21, 2019
@@ -127,7 +128,11 @@ trait ReceiveMessageDirectives {
<RequestId>{EmptyRequestId}</RequestId>
</ResponseMetadata>
</ReceiveMessageResponse>
}
}
case Left(sqsError) =>
Copy link
Member

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?

Copy link
Author

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 = {
Copy link
Member

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?

Copy link
Member

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
Copy link
Member

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?

Copy link
Author

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
Copy link
Member

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

Copy link
Author

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 _ => ()
Copy link
Member

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?

@Opalo Opalo closed this May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants