-
-
Notifications
You must be signed in to change notification settings - Fork 280
Using a local mock SQS server
It is possible to configure Shoryuken to use a local mock SQS server implementation in place of Amazon's real SQS. This is useful, for example, when doing local development without an Internet connection.
This guide will help you to configure one such mock SQS service implementation, moto
. We'll set up aws-sdk-ruby
and shoryuken
to use moto
instead of the real SQS provided by AWS.
Install moto with:
pip install moto[server]
To run it:
moto_server sqs -p 4576 -H localhost
To use a local SQS server, you must be running aws-sdk
version 2.2.15 or later. If your version of aws-sdk
is older, update it.
bundle update aws-sdk
We'll need to change the :sqs_endpoint
key of Shoryuken's AWS config to point to your local moto
instance. We'll also have to disable MD5 checks from send_message*
calls in the AWS SDK.
Shoryuken.configure_client do |config|
config.sqs_client = Aws::SQS::Client.new(
region: ENV["AWS_REGION"],
access_key_id: ENV["AWS_ACCESS_KEY_ID"],
secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
endpoint: 'http://localhost:4576',
verify_checksums: false
)
end
Shoryuken.configure_server do |config|
config.sqs_client = Aws::SQS::Client.new(
region: ENV["AWS_REGION"],
access_key_id: ENV["AWS_ACCESS_KEY_ID"],
secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
endpoint: 'http://localhost:4576',
verify_checksums: false
)
end
If you want to use shoryuken sqs
command with a different endpoint you can pass an --endpoint
option to the command, example:
shoryuken sqs ls --endpoint=http://localhost:4576
if you don't want to pass the --endpoint
option to all sqs
commands you can set an env var for it in the application SHORYUKEN_SQS_ENDPOINT=http://localhost:4576
.