GoLang SQS Queue Poller using the AWS SDK
This is based off of golang-sqs-worker-example but it uses the official AWS golang SDK.
Check out the cmd/example-worker/main.go for an example of how to use the worker.
An AWS SQS Poller
License: MIT License
GoLang SQS Queue Poller using the AWS SDK
This is based off of golang-sqs-worker-example but it uses the official AWS golang SDK.
Check out the cmd/example-worker/main.go for an example of how to use the worker.
Hi
when i try to created a new worker, the app fails with this error
go get github.com/h2ik/go-sqs-poller/v3/worker
cannot find package "github.com/h2ik/go-sqs-poller/v3/worker"
I've downloaded and started using the latest release of this repo. A notable change, aside from the code itself, was noted.
Previous behavior: When starting, the poller would output worker: Start Polling
once every 30 seconds
Current behavior: When starting, the poller would output worker: Start Polling
once every second
I figured this might be controlled by the WaitTimeSecond
property of &worker.Config
. However, changing that value didn't really change anything. So I digged into your source code and found the following:
go-sqs-poller/worker.go
inside the Start
function exists the following block of code:
params := &sqs.ReceiveMessageInput{
QueueUrl: aws.String(worker.Config.QueueURL), // Required
MaxNumberOfMessages: aws.Int64(worker.Config.MaxNumberOfMessage),
AttributeNames: []*string{
aws.String("All"), // Required
},
WaitTimeSeconds: aws.Int64(worker.Config.MaxNumberOfMessage),
}
If you notice the WaitTimeSeconds
paramter, it's using worker.Config.MaxNumberOfMessage
from the Config
struct. I changed that manually into worker.Config.WaitTimeSecond
and it started working as I expected.
I couldn't make sense of the whole thing because there are no comments regarding the struct itself.
Please let me know if I'm thinking correctly. If you wish, and I do make sense, I could open a Pull Request for it.
Thank you!
Because of the way QueueURL is defined, you can only run one of these polls in a given application/exectuable.
I've done some modifications in my fork - if these are acceptable to you, i can clean up the example and do a Pull Request.
I want to process by checking the attribute included in each message.
Please review adding MessageAttributeNames to the worker.go Start method as shown below.
params := &sqs.ReceiveMessageInput{
QueueUrl: aws.String(worker.Config.QueueURL), // Required
MaxNumberOfMessages: aws.Int64(worker.Config.MaxNumberOfMessage),
AttributeNames: []*string{
aws.String("All"), // Required
},
MessageAttributeNames: []*string{
aws.String(sqs.QueueAttributeNameAll),
},
WaitTimeSeconds: aws.Int64(worker.Config.WaitTimeSecond),
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.