Repository: softwaremill/elasticmq (scala)

Issue:
Each Queue's DelaySeconds parameter is always set to 0 when enabling queues-storage and reloading from a persisted queues config file.
Using the serverless-offline-sqs plugin along with Elasticmq running in a Docker container, and the serverless-offline-sqs plugin configured to autoCreate the Queues.

One of the Queues defined in the resources section of serverless.yml has a DelaySeconds parameter set to 600.

When first starting everything up, all Queues get auto-created as expected (verifiable via the Elasticmq Web UI and via its auto-generated persisted queues config file), and the DelaySeconds for the one Queue is correctly set to 600.

Upon stopping and restarting the Elasticmq container (forcing it to reload from its persisted queues config file), the one Queue's DelaySeconds parameter is now set to 0.  This is verifiable via the Elasticmq Web UI and via the persisted queues config file.

This issue is occurring in both the softwaremill/elasticmq-native and softwaremill/elasticmq container images.

Pull request description:
fixes #728

Patch:
diff --git a/persistence/persistence-file/src/main/scala/org/elasticmq/persistence/file/QueuePersister.scala b/persistence/persistence-file/src/main/scala/org/elasticmq/persistence/file/QueuePersister.scala
index edce1b5cf..1fa95a1f7 100644
--- a/persistence/persistence-file/src/main/scala/org/elasticmq/persistence/file/QueuePersister.scala
+++ b/persistence/persistence-file/src/main/scala/org/elasticmq/persistence/file/QueuePersister.scala
@@ -42,8 +42,8 @@ object QueuePersister {
   private def toQueueConfig(queue: QueueData): QueueMetadata =
     QueueMetadata(
       queue.defaultVisibilityTimeout.millis,
-      queue.delay.getStandardSeconds,
-      queue.receiveMessageWait.getStandardSeconds,
+      queue.delay.getMillis,
+      queue.receiveMessageWait.getMillis,
       queue.deadLettersQueue,
       queue.isFifo,
       queue.hasContentBasedDeduplication,


Test patch:
diff --git a/persistence/persistence-file/src/test/resources/two-queues-config.conf b/persistence/persistence-file/src/test/resources/two-queues-config.conf
index 13e916ebc..9cc240c27 100644
--- a/persistence/persistence-file/src/test/resources/two-queues-config.conf
+++ b/persistence/persistence-file/src/test/resources/two-queues-config.conf
@@ -1,4 +1,4 @@
 queues {
- test {contentBasedDeduplication=true,copyTo=copyTo,deadLettersQueue{maxReceiveCount=4,name=dead},defaultVisibilityTimeout=3000,delay=0,fifo=false,moveTo=messageTo,receiveMessageWait=0,tags{tag1Key=tag1Value},created=100,lastModified=200}
- test-2 {contentBasedDeduplication=true,copyTo=copyTo2,deadLettersQueue{maxReceiveCount=4,name=dead-2},defaultVisibilityTimeout=3000,delay=0,fifo=false,moveTo=messageTo2,receiveMessageWait=0,tags{tag12Key=tag12Value},created=100,lastModified=200}
+ test {contentBasedDeduplication=true,copyTo=copyTo,deadLettersQueue{maxReceiveCount=4,name=dead},defaultVisibilityTimeout=5000,delay=2000,fifo=false,moveTo=messageTo,receiveMessageWait=20000,tags{tag1Key=tag1Value},created=100,lastModified=200}
+ test-2 {contentBasedDeduplication=true,copyTo=copyTo2,deadLettersQueue{maxReceiveCount=4,name=dead-2},defaultVisibilityTimeout=3000,delay=1000,fifo=false,moveTo=messageTo2,receiveMessageWait=25000,tags{tag12Key=tag12Value},created=100,lastModified=200}
 }
\ No newline at end of file
diff --git a/persistence/persistence-file/src/test/scala/org/elasticmq/persistence/file/QueueConfigUtilTest.scala b/persistence/persistence-file/src/test/scala/org/elasticmq/persistence/file/QueueConfigUtilTest.scala
index 56670d38e..9baee31b8 100644
--- a/persistence/persistence-file/src/test/scala/org/elasticmq/persistence/file/QueueConfigUtilTest.scala
+++ b/persistence/persistence-file/src/test/scala/org/elasticmq/persistence/file/QueueConfigUtilTest.scala
@@ -73,9 +73,9 @@ class QueueConfigUtilTest extends AnyFunSuite with Matchers with OptionValues {
     val loadedQueues = CreateQueueMetadata.mergePersistedAndBaseQueues(queueConf, baseConf)
     val expectedQueue1 = CreateQueueMetadata(
       "test",
-      Some(3L),
-      Some(0L),
-      Some(0L),
+      Some(5L),
+      Some(2L),
+      Some(20L),
       100L,
       200L,
       Some(DeadLettersQueue("dead", 4)),
@@ -88,8 +88,8 @@ class QueueConfigUtilTest extends AnyFunSuite with Matchers with OptionValues {
     val expectedQueue2 = CreateQueueMetadata(
       "test-2",
       Some(3L),
-      Some(0L),
-      Some(0L),
+      Some(1L),
+      Some(25L),
       100L,
       200L,
       Some(DeadLettersQueue("dead-2", 4)),
diff --git a/persistence/persistence-file/src/test/scala/org/elasticmq/persistence/file/QueuePersisterTest.scala b/persistence/persistence-file/src/test/scala/org/elasticmq/persistence/file/QueuePersisterTest.scala
index de5097824..6ccf4b877 100644
--- a/persistence/persistence-file/src/test/scala/org/elasticmq/persistence/file/QueuePersisterTest.scala
+++ b/persistence/persistence-file/src/test/scala/org/elasticmq/persistence/file/QueuePersisterTest.scala
@@ -10,9 +10,9 @@ class QueuePersisterTest extends AnyFunSuite with Matchers {
     val queues = List(
       QueueData(
         name = "queue1",
-        defaultVisibilityTimeout = MillisVisibilityTimeout(10),
-        delay = Duration.ZERO,
-        receiveMessageWait = Duration.standardSeconds(10),
+        defaultVisibilityTimeout = MillisVisibilityTimeout.fromSeconds(10),
+        delay = Duration.standardSeconds(8),
+        receiveMessageWait = Duration.standardSeconds(3),
         created = new DateTime(),
         lastModified = new DateTime()
       )
@@ -21,7 +21,7 @@ class QueuePersisterTest extends AnyFunSuite with Matchers {
 
     actual shouldBe
       """queues {
-        | "queue1" {contentBasedDeduplication=false,copyTo="",defaultVisibilityTimeout=10,delay=0,fifo=false,moveTo="",receiveMessageWait=10,tags{}}
+        | "queue1" {contentBasedDeduplication=false,copyTo="",defaultVisibilityTimeout=10000,delay=8000,fifo=false,moveTo="",receiveMessageWait=3000,tags{}}
         |}""".stripMargin
   }
 
@@ -29,9 +29,9 @@ class QueuePersisterTest extends AnyFunSuite with Matchers {
     val queues = List(
       QueueData(
         name = "queue2.fifo",
-        defaultVisibilityTimeout = MillisVisibilityTimeout(10),
-        delay = Duration.ZERO,
-        receiveMessageWait = Duration.standardSeconds(10),
+        defaultVisibilityTimeout = MillisVisibilityTimeout.fromSeconds(10),
+        delay = Duration.standardSeconds(8),
+        receiveMessageWait = Duration.standardSeconds(3),
         created = new DateTime(),
         lastModified = new DateTime(),
         isFifo = true
@@ -41,7 +41,7 @@ class QueuePersisterTest extends AnyFunSuite with Matchers {
 
     actual shouldBe
       """queues {
-        | "queue2.fifo" {contentBasedDeduplication=false,copyTo="",defaultVisibilityTimeout=10,delay=0,fifo=true,moveTo="",receiveMessageWait=10,tags{}}
+        | "queue2.fifo" {contentBasedDeduplication=false,copyTo="",defaultVisibilityTimeout=10000,delay=8000,fifo=true,moveTo="",receiveMessageWait=3000,tags{}}
         |}""".stripMargin
   }