Skip to content

Commit

Permalink
Enabling long polling
Browse files Browse the repository at this point in the history
  • Loading branch information
STollenaar committed Sep 26, 2023
1 parent d1d53e4 commit 36bb515
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/sqspoller/sqspoller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"regexp"
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
Expand Down Expand Up @@ -54,6 +53,7 @@ func PollSQS() {
}

func pollSQS() {

for {
msgResult, err := sqsClient.ReceiveMessage(context.TODO(), &sqs.ReceiveMessageInput{
MessageAttributeNames: []string{
Expand All @@ -62,13 +62,14 @@ func pollSQS() {
QueueUrl: &util.ConfigFile.SQS_REQUEST,
MaxNumberOfMessages: 1,
VisibilityTimeout: int32(5),
WaitTimeSeconds: 10,
AttributeNames: []types.QueueAttributeName{types.QueueAttributeName(types.MessageSystemAttributeNameSentTimestamp)},
})
if err != nil {
fmt.Println("Got an error receiving messages:")
fmt.Println(err)
}
if msgResult == nil {
time.Sleep(time.Second*5)
continue
}
for _, message := range msgResult.Messages {
Expand Down

0 comments on commit 36bb515

Please sign in to comment.