-
Notifications
You must be signed in to change notification settings - Fork 468
Description
Steps to reproduce
docker-compose.yml
N/A// main.go
package main
import (
"log"
"context"
"github.com/ThreeDotsLabs/watermill"
watermillsqs "github.com/ThreeDotsLabs/watermill-aws/sqs"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/aws/aws-sdk-go-v2/config"
)
func main() {
ctx := context.Background()
cfg, _ := config.LoadDefaultConfig(ctx, config.WithRegion("eu-west-1"))
logger := watermill.NewStdLogger(false, false)
pub, err := watermillsqs.NewPublisher(watermillsqs.PublisherConfig{
AWSConfig: cfg,
DoNotCreateQueueIfNotExists: true,
QueueUrlResolver: watermillsqs.TransparentUrlResolver{},
}, logger)
if err != nil {
log.Fatal(err)
}
defer pub.Close()
msg := message.NewMessage(watermill.NewUUID(), []byte(`{"test": "data"}`))
queueURL := "https://sqs.eu-west-1.amazonaws.com/000011112222/my-existing-queue"
// HERE --> This always fails with: queue for topic ... doesn't exist
if err := pub.Publish(queueURL, msg); err != nil {
log.Fatalf("Failed to publish: %v", err)
}
log.Println("Published successfully")
}Expected behavior
The message should be published without creating a new SQS queue. Simple SendMessage on SQS
Actual behavior
The if-statement in GetQueueUrl statement always errors with fmt.Errorf("queue for topic %s doesn't exist", topic) error. The link - https://github.com/ThreeDotsLabs/watermill-aws/blob/master/sqs/publisher.go#L85
Possible solution
I think you could add more verbose logging on what happened, or comment "if you use this URL resolver setting DoNotCreateQueueIfNotExists to true will always error". But ideally the expected solution would be to simply SendMessage if we don't want to create a queue (you could also set Exists = true in TransparentUrlResolver).
I think there are many possible solutions - but I think the correct one depends widely on your decision.