Skip to content

Commit

Permalink
PurgeQueue support, 0.8.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Dec 11, 2014
1 parent 173e34a commit 1ad8466
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 32 deletions.
33 changes: 13 additions & 20 deletions README.md
Expand Up @@ -40,18 +40,18 @@ Installation: stand-alone
-------------------------

You can download the stand-alone distribution here:
[https://s3/.../elasticmq-server-0.8.4.jar](https://s3-eu-west-1.amazonaws.com/softwaremill-public/elasticmq-server-0.8.4.jar)
[https://s3/.../elasticmq-server-0.8.5.jar](https://s3-eu-west-1.amazonaws.com/softwaremill-public/elasticmq-server-0.8.5.jar)

Java 6 or above is required for running the server.

Simply run the jar and you should get a working server, which binds to `localhost:9324`:

java -jar elasticmq-server-0.8.4.jar
java -jar elasticmq-server-0.8.5.jar

ElasticMQ uses [Typesafe Config](https://github.com/typesafehub/config) for configuration. To specify custom
configuration values, create a file (e.g. `custom.conf`), fill it in with the desired values, and pass it to the server:

java -Dconfig.file=custom.conf -jar elasticmq-server-0.8.4.jar
java -Dconfig.file=custom.conf -jar elasticmq-server-0.8.5.jar

The config file may contain any configuration for Akka, Spray and ElasticMQ. Current ElasticMQ configuration values are:

Expand Down Expand Up @@ -83,7 +83,7 @@ You can also provide an alternative [Logback](http://logback.qos.ch/) configurat
[default](server/src/main/resources/logback.xml) is configured to
log INFO logs and above to the console):

java -Dlogback.configurationFile=my_logback.xml -jar elasticmq-server-0.8.4.jar
java -Dlogback.configurationFile=my_logback.xml -jar elasticmq-server-0.8.5.jar

Starting an embedded ElasticMQ server with an SQS interface
-----------------------------------------------------------
Expand Down Expand Up @@ -116,30 +116,19 @@ The endpoint value should be the same address as the `NodeAddress` provided as a

The `rest-sqs-testing-amazon-java-sdk` module contains some more usage examples.

Custom extensions
-----------------

ElasticMQ implements one additional endpoint, which can be useful during testing, above what is supported by SQS.

Making a request to:

[queue url]?Action=Clear

will remove all messages (both visibile and invisible) from the queue.

ElasticMQ dependencies in SBT
-----------------------------

// Scala 2.11
val elasticmqSqs = "org.elasticmq" %% "elasticmq-rest-sqs" % "0.8.4"
val elasticmqSqs = "org.elasticmq" %% "elasticmq-rest-sqs" % "0.8.5"

// Scala 2.10
val elasticmqSqs = "org.elasticmq" %% "elasticmq-rest-sqs" % "0.7.1"

If you don't want the SQS interface, but just use the actors directly, you can add a dependency only to the `core`
module:

val elasticmqCore = "org.elasticmq" %% "elasticmq-core" % "0.8.4"
val elasticmqCore = "org.elasticmq" %% "elasticmq-core" % "0.8.5"

If you want to use a snapshot version, you will need to add the [https://oss.sonatype.org/content/repositories/snapshots/](https://oss.sonatype.org/content/repositories/snapshots/) repository to your configuration.

Expand All @@ -151,7 +140,7 @@ Dependencies:
<dependency>
<groupId>org.elasticmq</groupId>
<artifactId>elasticmq-rest-sqs_2.11</artifactId>
<version>0.8.4</version>
<version>0.8.5</version>
</dependency>

If you want to use a snapshot version, you will need to add the [https://oss.sonatype.org/content/repositories/snapshots/](https://oss.sonatype.org/content/repositories/snapshots/) repository to your configuration.
Expand All @@ -165,9 +154,9 @@ have not yet been reimplemented using the new Akka core.
Current versions
----------------

*Stable*: 0.8.4
*Stable*: 0.8.5

*Development*: 0.8.5-SNAPSHOT
*Development*: 0.8.6-SNAPSHOT

Logging
-------
Expand Down Expand Up @@ -216,6 +205,10 @@ Technology
Change log
----------

#### Version 0.8.5 (11 Dec 2014)

* supporting `PurgeQueue` action instead of a custom one

#### Version 0.8.4 (2 Dec 2014)

* custom action for clearing all messages from a queue
Expand Down
4 changes: 2 additions & 2 deletions project/Build.scala
Expand Up @@ -6,7 +6,7 @@ import AssemblyKeys._
object BuildSettings {
val buildSettings = Defaults.coreDefaultSettings ++ Seq (
organization := "org.elasticmq",
version := "0.8.5-SNAPSHOT",
version := "0.8.5",
scalaVersion := "2.11.4",

addCompilerPlugin("org.scala-lang.plugins" % "scala-continuations-plugin_2.11.0" % "1.0.1"),
Expand Down Expand Up @@ -58,7 +58,7 @@ object Dependencies {
val mockito = "org.mockito" % "mockito-core" % "1.9.5"
val awaitility = "com.jayway.awaitility" % "awaitility-scala" % "1.6.0"

val amazonJavaSdk = "com.amazonaws" % "aws-java-sdk" % "1.9.1" exclude ("commons-logging", "commons-logging")
val amazonJavaSdk = "com.amazonaws" % "aws-java-sdk" % "1.9.10" exclude ("commons-logging", "commons-logging")

val akka2Version = "2.3.6"
val akka2Actor = "com.typesafe.akka" %% "akka-actor" % akka2Version
Expand Down
Expand Up @@ -764,6 +764,24 @@ class AmazonJavaSdkTestSuite extends FunSuite with MustMatchers with BeforeAndAf
result.isLeft must be (true)
}

test("should purge the queue") {
// Given
val queueUrl = client.createQueue(new CreateQueueRequest("testQueue1")).getQueueUrl

client.sendMessage(new SendMessageRequest(queueUrl, "Message 1"))
client.sendMessage(new SendMessageRequest(queueUrl, "Message 2"))
client.receiveMessage(new ReceiveMessageRequest(queueUrl).withMaxNumberOfMessages(1)).getMessages.get(0)

// When
client.purgeQueue(new PurgeQueueRequest().withQueueUrl(queueUrl))

// Then
val attributes = client.getQueueAttributes(new GetQueueAttributesRequest(queueUrl).withAttributeNames("All")).getAttributes
attributes.get("ApproximateNumberOfMessages") must be ("0")
attributes.get("ApproximateNumberOfMessagesNotVisible") must be ("0")
attributes.get("ApproximateNumberOfMessagesDelayed") must be ("0")
}

def queueVisibilityTimeout(queueUrl: String) = getQueueLongAttribute(queueUrl, visibilityTimeoutAttribute)

def queueDelay(queueUrl: String) = getQueueLongAttribute(queueUrl, delaySecondsAttribute)
Expand Down
Expand Up @@ -5,19 +5,19 @@ import org.elasticmq.msg.ClearQueue
import org.elasticmq.rest.sqs.Constants._
import org.elasticmq.rest.sqs.directives.ElasticMQDirectives

trait NonSQSDirectives { this: ElasticMQDirectives with QueueURLModule =>
val nonSQSDirectives = {
queueActorFromRequest { queueActor =>
action("Clear") {
trait PurgeQueueDirectives { this: ElasticMQDirectives with QueueURLModule =>
val purgeQueue = {
action("PurgeQueue") {
queueActorFromRequest { queueActor =>
for {
_ <- queueActor ? ClearQueue()
} yield {
respondWith {
<ClearQueueResponse>
<PurgeQueueResponse>
<ResponseMetadata>
<RequestId>{EmptyRequestId}</RequestId>
</ResponseMetadata>
</ClearQueueResponse>
</PurgeQueueResponse>
}
}
}
Expand Down
Expand Up @@ -103,7 +103,7 @@ case class TheSQSRestServerBuilder(providedActorSystem: Option[ActorSystem],
with ChangeMessageVisibilityDirectives
with ChangeMessageVisibilityBatchDirectives
with GetQueueUrlDirectives
with NonSQSDirectives
with PurgeQueueDirectives
with AttributesModule {

lazy val actorSystem = theActorSystem
Expand All @@ -125,14 +125,13 @@ case class TheSQSRestServerBuilder(providedActorSystem: Option[ActorSystem],
getQueueUrl ~
createQueue ~
listQueues ~
purgeQueue ~
// 3. Other
changeMessageVisibility ~
changeMessageVisibilityBatch ~
deleteQueue ~
getQueueAttributes ~
setQueueAttributes ~
// 4. Non-SQS
nonSQSDirectives
setQueueAttributes

val config = new ElasticMQConfig

Expand Down

0 comments on commit 1ad8466

Please sign in to comment.