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.52k stars 193 forks source link

Queues not created using java sdk #135

Closed willieowens closed 6 years ago

willieowens commented 6 years ago

Using gradle as a build system, and having multiple projects which would like to use the same queue, I decided to create another gradle project to start an elasticmq server with.

The build.gradle is as follows:

    compile 'org.elasticmq:elasticmq-rest-sqs_2.11:0.13.9'
}

apply plugin: 'application'

mainClassName = 'com.wowens.elasticmq.ElasticMqSqs'
applicationDefaultJvmArgs = ['-Dconfig.file=src/main/resources/com/wowens/elasticmq/elasticmq.conf']

Pretty simple. There is one class to start the queues, ElasticMqSqs, which is simply:


import org.elasticmq.rest.sqs.SQSRestServerBuilder;

public class ElasticMqSqs {

    public static void main(String[] args) {
        SQSRestServerBuilder.start();
    }
}

I have an elasticmq conf file in my resources:


queues {
    Queue1 {
    }
}

While the server starts up, it doesn't make a queue for me. If I use the same conf file with the jar directly it does create the queue...

ie.) java -Dconfig.file=elasticmq.conf -jar ~/Downloads/elasticmq-server-0.13.9.jar

Any thoughts? It seems to be picking up the conf file, as if I change the name/path it breaks cause it can't be found. If you suspect this may be a gradle-related issue, lmk.

Thanks, Willie

adamw commented 6 years ago

I think this might be gradle-specific, maybe -Dconfig.file when specified in applicationDefaultJvmArgs doesn't really set the system property?

willieowens commented 6 years ago

The system property gets set fine, as I can print it out. I've tried with relative and absolute paths as well.

I've taken gradle out of the equation and get the same results. Am I missing something from the java sdk?

wowens@ATL-WOWENS:~/Downloads$ cat queue.conf 
include classpath("application.conf")

queues {
    TestQueue {
    }
}

wowens@ATL-WOWENS:~/Downloads$ cat QueueTest.java 
import org.elasticmq.rest.sqs.SQSRestServerBuilder;

public class QueueTest {

    public static void main(String[] args) {

        System.out.println("config.file: " + System.getProperty("config.file"));

        SQSRestServerBuilder.start();
    }
}

wowens@ATL-WOWENS:~/Downloads$ javac -cp ".:elasticmq-server-0.13.9.jar" QueueTest.java 

wowens@ATL-WOWENS:~/Downloads$ java -Dconfig.file=queue.conf -cp ".:elasticmq-server-0.13.9.jar" QueueTestconfig.file: queue.conf
09:17:22.209 [elasticmq-akka.actor.default-dispatcher-4] INFO  akka.event.slf4j.Slf4jLogger - Slf4jLogger started
09:17:23.104 [elasticmq-akka.actor.default-dispatcher-4] INFO  o.e.rest.sqs.SQSRestServerBuilder$ - Started SQS rest server, bind address :9324, visible server address http://localhost:9324

Standalone jar works:

wowens@ATL-WOWENS:~/Downloads$ java -Dconfig.file=queue.conf -jar elasticmq-server-0.13.9.jar 
09:17:55.936 [main] INFO  org.elasticmq.server.Main$ - Starting ElasticMQ server (0.13.9) ...
09:17:56.564 [elasticmq-akka.actor.default-dispatcher-3] INFO  akka.event.slf4j.Slf4jLogger - Slf4jLogger started
09:17:57.311 [elasticmq-akka.actor.default-dispatcher-3] INFO  o.e.rest.sqs.TheSQSRestServerBuilder - Started SQS rest server, bind address 0.0.0.0:9324, visible server address http://localhost:9324
09:17:57.358 [elasticmq-akka.actor.default-dispatcher-2] INFO  o.elasticmq.actor.QueueManagerActor - Creating queue QueueData(TestQueue,MillisVisibilityTimeout(30000),PT0S,PT0S,2018-04-23T09:17:57.316-04:00,2018-04-23T09:17:57.316-04:00,None,None)
09:17:57.364 [main] INFO  org.elasticmq.server.Main$ - === ElasticMQ server (0.13.9) started in 1792 ms ===
^C09:17:59.462 [Thread-1] INFO  org.elasticmq.server.Main$ - ElasticMQ server stopping ...
09:17:59.522 [Thread-1] INFO  org.elasticmq.server.Main$ - === ElasticMQ server stopped ===
adamw commented 6 years ago

ah 🤦‍♂️ sorry, the queues from the config file only get created when you run org.elasticmq.server.Main from the elasticmq-server project. That's probably why things don't work as expected :)

willieowens commented 6 years ago

I was gonna ask if that was the case haha, that makes sense. Thanks!