Created
February 3, 2016 19:20
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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