From edfff69a659b5a8b60f7efde8347e0b0a507328b Mon Sep 17 00:00:00 2001 From: Paul Fortin Date: Thu, 19 May 2016 12:51:36 -0400 Subject: [PATCH 1/4] Change start of ElasticMq from rest only to server+rest for backwards compatibility (i.e: python boto) --- project.clj | 1 + src/com/unbounce/yopa/sqs_server.clj | 34 +++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/project.clj b/project.clj index af55466..746e6de 100644 --- a/project.clj +++ b/project.clj @@ -37,6 +37,7 @@ [circleci/clj-yaml "0.5.3"] [de.ubercode.clostache/clostache "1.4.0"] + [org.elasticmq/elasticmq-server_2.11 "0.8.8" :exclusions [joda-time]] [org.elasticmq/elasticmq-rest-sqs_2.11 "0.8.8" :exclusions [joda-time]] [amazonica "0.3.29" :exclusions [com.amazonaws/aws-java-sdk]] [com.amazonaws/aws-java-sdk-sqs ~aws-sdk-version :exclusions [joda-time]] diff --git a/src/com/unbounce/yopa/sqs_server.clj b/src/com/unbounce/yopa/sqs_server.clj index 74b8fcd..3963094 100644 --- a/src/com/unbounce/yopa/sqs_server.clj +++ b/src/com/unbounce/yopa/sqs_server.clj @@ -3,10 +3,39 @@ [amazonica.aws.sqs :as sqs] [clojure.tools.logging :as log]) (:import org.elasticmq.rest.sqs.SQSRestServerBuilder - org.elasticmq.NodeAddress)) + org.elasticmq.server.ElasticMQServer + org.elasticmq.server.ElasticMQServerConfig + org.elasticmq.NodeAddress + com.typesafe.config.ConfigObject + com.typesafe.config.ConfigFactory + com.typesafe.config.Config)) + +(def config-string "{ + \"storage\": { + \"type\" = \"in-memory\" + }, + \"node-address\":{ + \"protocol\":\"http\", + \"host\":\"localhost\", + \"port\":\"47195\", + \"context-path\":\"\" + }, + \"rest-sqs\":{ + \"enabled\":\"true\", + \"bind-port\":\"47195\", + \"bind-hostname\":\"0.0.0.0\", + \"sqs-limits\":\"strict\" + } +}") (def ^:private ^:dynamic server (atom nil)) +(defn- make-main-server [] + (let [typesafe-config (ConfigFactory/parseString config-string)] + (let [config (ElasticMQServerConfig. typesafe-config)] + (-> (ElasticMQServer. config) + (.start))))) + (defn- make-server [host bind-address port] (let [address (NodeAddress. "http", host, port, "")] (-> (SQSRestServerBuilder/withPort port) @@ -16,8 +45,7 @@ (.start)))) (defn start [host bind-address port] - (reset! server (make-server host bind-address port)) - (.waitUntilStarted @server) + (reset! server (make-main-server)) (log/info (format "Active SQS endpoint: http://%s:%d" bind-address port))) (defn stop [] From 62df488fa29661f2687d1df8771d539e356e7bff Mon Sep 17 00:00:00 2001 From: Paul Fortin Date: Thu, 19 May 2016 13:12:04 -0400 Subject: [PATCH 2/4] Change start of ElasticMq from rest only to server+rest for backwards compatibility (i.e: python boto) --- project.clj | 1 + src/com/unbounce/yopa/sqs_server.clj | 35 ++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/project.clj b/project.clj index af55466..746e6de 100644 --- a/project.clj +++ b/project.clj @@ -37,6 +37,7 @@ [circleci/clj-yaml "0.5.3"] [de.ubercode.clostache/clostache "1.4.0"] + [org.elasticmq/elasticmq-server_2.11 "0.8.8" :exclusions [joda-time]] [org.elasticmq/elasticmq-rest-sqs_2.11 "0.8.8" :exclusions [joda-time]] [amazonica "0.3.29" :exclusions [com.amazonaws/aws-java-sdk]] [com.amazonaws/aws-java-sdk-sqs ~aws-sdk-version :exclusions [joda-time]] diff --git a/src/com/unbounce/yopa/sqs_server.clj b/src/com/unbounce/yopa/sqs_server.clj index 74b8fcd..6088ba8 100644 --- a/src/com/unbounce/yopa/sqs_server.clj +++ b/src/com/unbounce/yopa/sqs_server.clj @@ -3,10 +3,39 @@ [amazonica.aws.sqs :as sqs] [clojure.tools.logging :as log]) (:import org.elasticmq.rest.sqs.SQSRestServerBuilder - org.elasticmq.NodeAddress)) + org.elasticmq.server.ElasticMQServer + org.elasticmq.server.ElasticMQServerConfig + org.elasticmq.NodeAddress + com.typesafe.config.ConfigObject + com.typesafe.config.ConfigFactory + com.typesafe.config.Config)) + +(def config-string "{ + \"storage\": { + \"type\" = \"in-memory\" + }, + \"node-address\":{ + \"protocol\":\"http\", + \"host\":\"localhost\", + \"port\":\"47195\", + \"context-path\":\"\" + }, + \"rest-sqs\":{ + \"enabled\":\"true\", + \"bind-port\":\"47195\", + \"bind-hostname\":\"0.0.0.0\", + \"sqs-limits\":\"strict\" + } +}") (def ^:private ^:dynamic server (atom nil)) +(defn- make-main-server [] + (let [typesafe-config (ConfigFactory/parseString config-string)] + (let [config (ElasticMQServerConfig. typesafe-config)] + (-> (ElasticMQServer. config) + (.start))))) + (defn- make-server [host bind-address port] (let [address (NodeAddress. "http", host, port, "")] (-> (SQSRestServerBuilder/withPort port) @@ -16,11 +45,9 @@ (.start)))) (defn start [host bind-address port] - (reset! server (make-server host bind-address port)) - (.waitUntilStarted @server) + (reset! server (make-main-server)) (log/info (format "Active SQS endpoint: http://%s:%d" bind-address port))) (defn stop [] (when @server - (.stopAndWait @server) (reset! server nil))) From b18dc01a530ca761221c0b8e23e60024eecd5945 Mon Sep 17 00:00:00 2001 From: Michael Shannon Date: Thu, 19 May 2016 15:27:12 -0400 Subject: [PATCH 3/4] Add Extra Config --- src/com/unbounce/yopa/sqs_server.clj | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/unbounce/yopa/sqs_server.clj b/src/com/unbounce/yopa/sqs_server.clj index 6088ba8..6f00d8c 100644 --- a/src/com/unbounce/yopa/sqs_server.clj +++ b/src/com/unbounce/yopa/sqs_server.clj @@ -11,12 +11,21 @@ com.typesafe.config.Config)) (def config-string "{ + \"akka.http.server.parsing.illegal-header-warnings\": \"off\", + \"akka\": { + \"loggers\": [\"akka.event.slf4j.Slf4jLogger\"], + \"loglevel\": \"DEBUG\", + \"logging-filter\": \"akka.event.slf4j.Slf4jLoggingFilter\", + \"log-dead-letters-during-shutdown\": false + } + \"akka.http.server.request-timeout\": \"21 s\", + \"akka.http.server.parsing.max-uri-length\": \"256k\", \"storage\": { \"type\" = \"in-memory\" }, \"node-address\":{ \"protocol\":\"http\", - \"host\":\"localhost\", + \"host\":\"0.0.0.0\", \"port\":\"47195\", \"context-path\":\"\" }, @@ -24,7 +33,7 @@ \"enabled\":\"true\", \"bind-port\":\"47195\", \"bind-hostname\":\"0.0.0.0\", - \"sqs-limits\":\"strict\" + \"sqs-limits\":\"relaxed\" } }") From ddc03af1fa426675a1ed46d12b63efe7997b0217 Mon Sep 17 00:00:00 2001 From: Michael Shannon Date: Sat, 21 May 2016 16:01:05 -0400 Subject: [PATCH 4/4] SQS Update - Pass Host/Port & Update to 8.12 --- project.clj | 10 +++--- src/com/unbounce/yopa/sqs_server.clj | 50 ++++++++++++---------------- 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/project.clj b/project.clj index 746e6de..630554b 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(def project-version "1.0.0-SNAPSHOT") +(def project-version "1.0.1-SNAPSHOT") (def build-meta (str "YOPA " project-version " - built on: " (java.util.Date.))) (def ring-version "1.3.2") (def aws-sdk-version "1.10.5.1") @@ -37,8 +37,8 @@ [circleci/clj-yaml "0.5.3"] [de.ubercode.clostache/clostache "1.4.0"] - [org.elasticmq/elasticmq-server_2.11 "0.8.8" :exclusions [joda-time]] - [org.elasticmq/elasticmq-rest-sqs_2.11 "0.8.8" :exclusions [joda-time]] + [org.elasticmq/elasticmq-server_2.11 "0.8.12" :exclusions [joda-time]] + [org.elasticmq/elasticmq-rest-sqs_2.11 "0.8.12" :exclusions [joda-time]] [amazonica "0.3.29" :exclusions [com.amazonaws/aws-java-sdk]] [com.amazonaws/aws-java-sdk-sqs ~aws-sdk-version :exclusions [joda-time]] [com.amazonaws/aws-java-sdk-sns ~aws-sdk-version :exclusions [joda-time]] @@ -54,9 +54,7 @@ [ring/ring-core ~ring-version] [ring/ring-jetty-adapter ~ring-version] - [org.jruby/jruby "9.0.0.0" :exclusions [com.github.jnr/jffi - com.github.jnr/jnr-x86asm - joda-time]] + [org.jruby/jruby "9.0.0.0" :exclusions [joda-time]] ] :repositories diff --git a/src/com/unbounce/yopa/sqs_server.clj b/src/com/unbounce/yopa/sqs_server.clj index 6f00d8c..eb4d6f2 100644 --- a/src/com/unbounce/yopa/sqs_server.clj +++ b/src/com/unbounce/yopa/sqs_server.clj @@ -2,11 +2,8 @@ (:require [amazonica.core :as aws] [amazonica.aws.sqs :as sqs] [clojure.tools.logging :as log]) - (:import org.elasticmq.rest.sqs.SQSRestServerBuilder - org.elasticmq.server.ElasticMQServer + (:import org.elasticmq.server.ElasticMQServer org.elasticmq.server.ElasticMQServerConfig - org.elasticmq.NodeAddress - com.typesafe.config.ConfigObject com.typesafe.config.ConfigFactory com.typesafe.config.Config)) @@ -17,44 +14,39 @@ \"loglevel\": \"DEBUG\", \"logging-filter\": \"akka.event.slf4j.Slf4jLoggingFilter\", \"log-dead-letters-during-shutdown\": false - } + }, \"akka.http.server.request-timeout\": \"21 s\", \"akka.http.server.parsing.max-uri-length\": \"256k\", \"storage\": { - \"type\" = \"in-memory\" + \"type\": \"in-memory\" }, - \"node-address\":{ - \"protocol\":\"http\", - \"host\":\"0.0.0.0\", - \"port\":\"47195\", - \"context-path\":\"\" + \"node-address\": { + \"protocol\": \"http\", + \"host\": \"%s\", + \"port\": \"%d\", + \"context-path\": \"\" }, - \"rest-sqs\":{ - \"enabled\":\"true\", - \"bind-port\":\"47195\", - \"bind-hostname\":\"0.0.0.0\", - \"sqs-limits\":\"relaxed\" - } + \"rest-sqs\": { + \"enabled\": true, + \"bind-hostname\": \"%s\", + \"bind-port\": \"%d\", + \"sqs-limits\": \"relaxed\" + }, + \"queues\": {} }") (def ^:private ^:dynamic server (atom nil)) -(defn- make-main-server [] - (let [typesafe-config (ConfigFactory/parseString config-string)] +(defn- make-main-server [host bind-address port] + (let [formatted-config (format config-string host port bind-address port)] + (log/info formatted-config) + (let [typesafe-config (ConfigFactory/parseString formatted-config)] (let [config (ElasticMQServerConfig. typesafe-config)] (-> (ElasticMQServer. config) - (.start))))) - -(defn- make-server [host bind-address port] - (let [address (NodeAddress. "http", host, port, "")] - (-> (SQSRestServerBuilder/withPort port) - (.withInterface bind-address) - (.withPort port) - (.withServerAddress address) - (.start)))) + (.start)))))) (defn start [host bind-address port] - (reset! server (make-main-server)) + (reset! server (make-main-server host bind-address port)) (log/info (format "Active SQS endpoint: http://%s:%d" bind-address port))) (defn stop []