Skip to content

Commit c800d46

Browse files
committed
Fix queue recreation issue by appending random postfix to actor name; add test for multiple recreations
1 parent 7cdb4a9 commit c800d46

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

core/src/main/scala/org/elasticmq/actor/QueueManagerActor.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.elasticmq.actor.reply._
77
import org.elasticmq.msg._
88
import org.elasticmq.util.{Logging, NowProvider}
99

10+
import java.util.UUID
1011
import scala.collection.mutable
1112
import scala.reflect._
1213

@@ -95,6 +96,9 @@ class QueueManagerActor(nowProvider: NowProvider, limits: Limits, queueEventList
9596
queues.get(queueName).map(_.actorRef)
9697
}
9798

99+
// Generate a random postfix to fix a rare issue with recreating queue with the same name
100+
val actorNamePostfix = UUID.randomUUID().toString.take(8)
101+
98102
context.actorOf(
99103
Props(
100104
new QueueActor(
@@ -106,7 +110,7 @@ class QueueManagerActor(nowProvider: NowProvider, limits: Limits, queueEventList
106110
queueEventListener
107111
)
108112
),
109-
s"queue-${queueData.name}"
113+
s"queue-${queueData.name}-$actorNamePostfix"
110114
)
111115
}
112116

rest/rest-sqs/src/test/scala/org/elasticmq/rest/stats/StatisticsDirectivesTest.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ class StatisticsDirectivesTest
5353

5454
lazy val contextPath = ""
5555

56+
it should "recreate a queue with the same name multiple times" in {
57+
for (i <- 1 to 10) {
58+
createQueueWithName("firstQueue")
59+
deleteQueueWithName("firstQueue")
60+
}
61+
}
62+
5663
"statisticsRequestForAllQueues" should "return all queues statistics" in {
5764

5865
val route = {

0 commit comments

Comments
 (0)