Skip to content

Instantly share code, notes, and snippets.

@wangkuiyi
Created February 3, 2016 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangkuiyi/87f0c0d64e5d689ee0f2 to your computer and use it in GitHub Desktop.
Save wangkuiyi/87f0c0d64e5d689ee0f2 to your computer and use it in GitHub Desktop.
How to use https://github.com/AdRoll/goamz/tree/master/s3 to create SQS queues as well as read/write with it.
package main
import (
"fmt"
"time"
"github.com/AdRoll/goamz/aws"
"github.com/AdRoll/goamz/sqs"
"github.com/davecgh/go-spew/spew"
. "github.com/topicai/candy"
)
var (
integrationTesterAccessKey = // key
integrationTesterSecretKey = // secret key
integrationTesterRegion = aws.USWest2
)
func main() {
learnSQS()
}
func learnSQS() {
queueService := sqs.New(
aws.Auth{
AccessKey: integrationTesterAccessKey,
SecretKey: integrationTesterSecretKey},
integrationTesterRegion)
queue, e := queueService.CreateQueue(fmt.Sprintf("testing-img-proc-%v", time.Now().UnixNano()))
Must(e)
_, e = queue.SendMessageBatch(
[]sqs.Message{
sqs.Message{
MessageId: "0",
Body: "hello"},
sqs.Message{
MessageId: "1",
Body: "world!"}})
Must(e)
r, e := queue.ReceiveMessage(10)
Must(e)
for _, msg := range r.Messages {
spew.Dump("Recieved: ", msg)
}
_, e = queue.Delete()
Must(e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment