diff options
author | Nick White <git@njw.name> | 2020-05-19 15:23:55 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2020-05-19 15:23:55 +0100 |
commit | 60af66d9ba77a61e61ef71d02c8e30198c433c87 (patch) | |
tree | 8855ef5d7674b84cb065627768fefea13577f8c4 /aws.go | |
parent | a16886789683abaf427a73144e77750c0119f0c3 (diff) |
Add getandpurgequeue debugging tool
Diffstat (limited to 'aws.go')
-rw-r--r-- | aws.go | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -149,6 +149,35 @@ func (a *AwsConn) CheckQueue(url string, timeout int64) (Qmsg, error) { } } +func (a *AwsConn) LogAndPurgeQueue(url string) error { + for { + msgResult, err := a.sqssvc.ReceiveMessage(&sqs.ReceiveMessageInput{ + MaxNumberOfMessages: aws.Int64(10), + VisibilityTimeout: aws.Int64(300), + QueueUrl: &url, + }) + if err != nil { + return err + } + + if len(msgResult.Messages) > 0 { + for _, m := range msgResult.Messages { + a.Logger.Println(*m.Body) + _, err = a.sqssvc.DeleteMessage(&sqs.DeleteMessageInput{ + QueueUrl: &url, + ReceiptHandle: m.ReceiptHandle, + }) + if err != nil { + return err + } + } + } else { + break + } + } + return nil +} + // QueueHeartbeat updates the visibility timeout of a message. This // ensures that the message remains "in flight", meaning that it // cannot be seen by other processes, but if this process fails the |