softwaremill / elasticmq

In-memory message queue with an Amazon SQS-compatible interface. Runs stand-alone or embedded.
https://softwaremill.com/open-source/
Apache License 2.0
2.56k stars 195 forks source link

Exception calling `createQueue` #1050

Closed MatteoFeltrin closed 1 month ago

MatteoFeltrin commented 1 month ago
    private \AsyncAws\Sqs\SqsClient $client;

    public function createFifoQueue(string $queueName): string
    {
        $result = $this->client->createQueue(
            [
                'Attributes' => [
                    QueueAttributeName::FIFO_QUEUE => 'true',
                    QueueAttributeName::RECEIVE_MESSAGE_WAIT_TIME_SECONDS => 0,
                    QueueAttributeName::CONTENT_BASED_DEDUPLICATION => 'false',
                ],
                'QueueName' => $queueName,
            ]
        );

        return $result->getQueueUrl();
    }

Running this code is throwing this exception 4 times and then sqsClient says HTTP 500 returned for "...url...":

15:14:26.298 [elasticmq-pekko.actor.default-dispatcher-9] ERROR o.e.r.s.TheSQSRestServerBuilder$$anon$1 - Exception when running routes
2024-09-19T15:14:26.298489263Z spray.json.DeserializationException: Expected String as JsString, but got 0
2024-09-19T15:14:26.298496161Z  at spray.json.package$.deserializationError(package.scala:23)
2024-09-19T15:14:26.298498402Z  at spray.json.ProductFormats.fromField(ProductFormats.scala:63)
2024-09-19T15:14:26.298500181Z  at spray.json.ProductFormats.fromField$(ProductFormats.scala:51)
2024-09-19T15:14:26.298501950Z  at spray.json.DefaultJsonProtocol$.fromField(DefaultJsonProtocol.scala:30)
2024-09-19T15:14:26.298503826Z  at spray.json.ProductFormatsInstances$$anon$3.read(ProductFormatsInstances.scala:82)
2024-09-19T15:14:26.298505844Z  at spray.json.ProductFormatsInstances$$anon$3.read(ProductFormatsInstances.scala:71)
2024-09-19T15:14:26.298507855Z  at spray.json.JsValue.convertTo(JsValue.scala:33)
2024-09-19T15:14:26.298509598Z  at org.elasticmq.rest.sqs.model.RequestPayload$JsonParams.readAs(RequestPayload.scala:29)
2024-09-19T15:14:26.298511375Z  at org.elasticmq.rest.sqs.model.RequestPayload.as(RequestPayload.scala:15)
2024-09-19T15:14:26.298513130Z  at org.elasticmq.rest.sqs.model.RequestPayload.as$(RequestPayload.scala:14)
2024-09-19T15:14:26.298514901Z  at org.elasticmq.rest.sqs.model.RequestPayload$JsonParams.as(RequestPayload.scala:27)
2024-09-19T15:14:26.298516718Z  at org.elasticmq.rest.sqs.CreateQueueDirectives.$anonfun$createQueue$1(CreateQueueDirectives.scala:29)
2024-09-19T15:14:26.298518558Z  at org.apache.pekko.http.scaladsl.server.Directive$.$anonfun$addByNameNullaryApply$2(Directive.scala:184)
2024-09-19T15:14:26.298520391Z  at org.apache.pekko.http.scaladsl.server.Directive$.$anonfun$Empty$1(Directive.scala:170)
2024-09-19T15:14:26.298522293Z  at org.apache.pekko.http.scaladsl.server.Directive$$anon$1.tapply(Directive.scala:165)
2024-09-19T15:14:26.298524194Z  at org.apache.pekko.http.scaladsl.server.Directive$.$anonfun$addByNameNullaryApply$1(Directive.scala:184)
2024-09-19T15:14:26.298526108Z  at org.elasticmq.rest.sqs.CreateQueueDirectives.createQueue(CreateQueueDirectives.scala:27)
2024-09-19T15:14:26.298528010Z  at org.elasticmq.rest.sqs.CreateQueueDirectives.createQueue$(CreateQueueDirectives.scala:25)
2024-09-19T15:14:26.298529959Z  at org.elasticmq.rest.sqs.TheSQSRestServerBuilder$$anon$1.createQueue(SQSRestServerBuilder.scala:144)
2024-09-19T15:14:26.298541428Z  at org.elasticmq.rest.sqs.TheSQSRestServerBuilder.rawRoutes$1(SQSRestServerBuilder.scala:202)
2024-09-19T15:14:26.298543400Z  at org.elasticmq.rest.sqs.TheSQSRestServerBuilder.$anonfun$start$8(SQSRestServerBuilder.scala:244)
2024-09-19T15:14:26.298546177Z  at org.elasticmq.rest.sqs.directives.AnyParamDirectives.$anonfun$anyParamsMap$3(AnyParamDirectives.scala:76)
2024-09-19T15:14:26.298548261Z  at org.apache.pekko.http.scaladsl.server.util.ApplyConverterInstances$$anon$1.$anonfun$apply$1(ApplyConverterInstances.scala:23)
2024-09-19T15:14:26.298550320Z  at org.apache.pekko.http.scaladsl.server.ConjunctionMagnet$$anon$2.$anonfun$apply$3(Directive.scala:255)
2024-09-19T15:14:26.298554394Z  at org.apache.pekko.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResult$2(BasicDirectives.scala:80)
2024-09-19T15:14:26.298556376Z  at org.apache.pekko.http.scaladsl.server.directives.FutureDirectives.$anonfun$onComplete$3(FutureDirectives.scala:47)
2024-09-19T15:14:26.298558295Z  at org.apache.pekko.http.scaladsl.util.FastFuture$.$anonfun$transformWith$1(FastFuture.scala:45)
2024-09-19T15:14:26.298560200Z  at org.apache.pekko.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:49)
2024-09-19T15:14:26.298562135Z  at org.apache.pekko.http.scaladsl.util.FastFuture$.$anonfun$transformWith$3(FastFuture.scala:59)
2024-09-19T15:14:26.298564038Z  at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:484)
2024-09-19T15:14:26.298565953Z  at org.apache.pekko.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:73)
2024-09-19T15:14:26.298567888Z  at org.apache.pekko.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:110)
2024-09-19T15:14:26.298569865Z  at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
2024-09-19T15:14:26.298571799Z  at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
2024-09-19T15:14:26.298573696Z  at org.apache.pekko.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:110)
2024-09-19T15:14:26.298575629Z  at org.apache.pekko.dispatch.TaskInvocation.run(AbstractDispatcher.scala:59)
2024-09-19T15:14:26.298577589Z  at org.apache.pekko.dispatch.ForkJoinExecutorConfigurator$PekkoForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:57)
2024-09-19T15:14:26.298579576Z  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
2024-09-19T15:14:26.298581516Z  at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
2024-09-19T15:14:26.298583457Z  at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
2024-09-19T15:14:26.298585377Z  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
2024-09-19T15:14:26.298587278Z  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
2024-09-19T15:14:26.298589221Z  at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
2024-09-19T15:14:26.298593802Z  at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
micossow commented 1 month ago

@MatteoFeltrin attribute map is of a type "string" -> "string" according to the docs: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html#API_CreateQueue_RequestSyntax

It is possible, that you can pass a number literal in your request to AWS SQS, but we try to stick to the docs.

MatteoFeltrin commented 1 month ago

@micossow Sorry my bad, you are right, with all string paramters it works 😅