在开发过程中模拟 AmazonSQS

我对使用 Amazon SQS (也许还有 SimpleDB)开始一些开发非常感兴趣,我的问题是,是否存在模仿这些功能的开源解决方案,只是为了开发的目的。我已经遇到了 Eucalyptus 项目(http://open.eucalyptus.com)来创建 EC 风格的云。

我没有任何成功的谷歌,我怀疑这是因为进入的成本是如此便宜,但仍然,有人知道这样的事情吗?

69504 次浏览

Some of the Amazon SDKs have "mock" mode, which is:

The mock service is an alternate way to use the sample code. The service doesn't call AWS, but instead returns a set response that you can modify to suit your needs (the XML response files are in the Mock directory). The mock service makes it easy for you to test how your application handles different responses.

For SQS, it appears the Perl and PHP SDKs have mock mode. I know that the .NET SDK for Amazon RDS also has the mock mode.

The Java SDK doesn't contain mock implementations:

The client mock implementations have been removed. Instead, developers are encouraged to use more flexible and full featured mock libraries, such as EasyMock, jMock

If the SDK you will be using doesn't have the mock mode available, you could probably create your own similar type of thing which returns the preconfigured responses instead of actually hitting up the service.

See here for more info

If you are in .NET or Mono you can try Stratosphere. It has local implementations that mimic SimpleDB, SQS and S3. For SimpleDB mock implementation it uses SQLite, for SQS and S3 it stores messages/objects in file system.

For SQS I wrote ElasticMQ, which you can run either embedded (it's written in Scala, so runs on the JVM) or stand-alone. It has both persistent and in-memory modes, the first being good for dev, second for testing.

Regarding the Java SDK, it does no longer contain mock implementations:

The client mock implementations have been removed. Instead, developers are encouraged to use more flexible and full featured mock libraries, such as EasyMock, jMock

if you need to simulate SNS as well as SQS you can check out: Yopa

GoAws - https://github.com/p4tin/goaws - was just released as beta. (disclaimer - I am the developer).

If you need a test double for more than just SQS, you can try LocalStack.

To simulate SQS, it internally uses ElasticMQ mentioned by adamw.

You can start LocalStack via Docker, for example, and it will start the following services: