Last active
August 29, 2015 14:23
-
-
Save ikawaha/44161ff935442d1f8381 to your computer and use it in GitHub Desktop.
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/goamz/goamz/aws" | |
"github.com/goamz/goamz/sqs" | |
"github.com/k0kubun/pp" | |
) | |
func main() { | |
auth := aws.Auth{ | |
AccessKey: "", //os.Getenv("TEST"), | |
SecretKey: "", //os.Getenv("TEST"), | |
} | |
region := aws.Region{ | |
Name: "localhost", | |
SQSEndpoint: "http://localhost:9324", | |
} | |
conn := sqs.New(auth, region) | |
fmt.Println(conn) | |
q, err := conn.GetQueue("PushQueue") | |
if err != nil { | |
fmt.Errorf("error:", err.Error()) | |
} | |
fmt.Println("queue:", q) | |
for { | |
rcv, err := q.ReceiveMessage(10) | |
if err != nil { | |
fmt.Errorf("rcv error:", err.Error()) | |
} | |
//pp.Println("receive:", rcv) | |
for _, m := range rcv.Messages { | |
del, err := q.DeleteMessageUsingReceiptHandle(m.ReceiptHandle) | |
if err != nil { | |
fmt.Errorf("del error:", err.Error()) | |
continue | |
} | |
pp.Println("receive:", m) | |
pp.Println("deleted:", del) | |
} | |
time.Sleep(100 * time.Millisecond) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment