Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using different Amazon*Clients for multhreading #353

Open
pablobcb opened this issue Dec 6, 2017 · 3 comments
Open

using different Amazon*Clients for multhreading #353

pablobcb opened this issue Dec 6, 2017 · 3 comments

Comments

@pablobcb
Copy link

pablobcb commented Dec 6, 2017

Hello,

I have an application using SQS, and i'd like to consume/process it from different threads ...
but after the msgs are in flight, the other threads cant fetch new msgs

Looking at the docs ive found:

Note: The first function called (for each distinct AWS service namespace, e.g. amazonica.aws.ec2)
 creates an Amazon*Client, which is effectively cached via memoization. Therefore, if you explicitly pass different credentials maps to different functions, you will effectively have different Clients.

I guess this is the reason behind it.. is there a way to use individual clients (or another proper solution) so each thread can process its own batch (of 10 msgs) ?

thanks!

@mcohen01
Copy link
Owner

mcohen01 commented Dec 6, 2017

you can consume from the queue inside multiple (future....)

@pablobcb
Copy link
Author

pablobcb commented Dec 7, 2017

Not sure if I got it right ... lets suppose I have 100 msgs (0 in-flight), and I'd like to print them all
this should do the trick?

(dotimes [_ 10]
  (future
   (let [payload (sqs/receive-message aws-cfg
                   {:max-number-of-messages 10
                    :queue-url              queue-url})]
     (prn payload))))

Because right now the first thread print 10 msgs and the other 9 receive an empty list (like there are no msgs in the queue)

thank you for the fast response!

@mcohen01
Copy link
Owner

mcohen01 commented Dec 8, 2017

you may want to try adding wait-time-seconds to your receive-message calls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants