Niko Sams
Niko Sams

Reputation: 4404

Get Message from AWS SQS using Php without polling

Is there a way to write a Php consumer for SQS that doesn't have to poll periodically for new messages?

The only way to consume messages I found so far is getting them using the receive_message() api call which needs to be done using periodical polling.

While it should work it still seems wrong.

Upvotes: 1

Views: 2556

Answers (2)

Jonathan
Jonathan

Reputation: 986

I know this is a really old question, but just wanted to point this out for future readers.

SQS is meant for polling, but if you want a push solution, you can actually choose 'Queue Options' on the AWS SQS panel, and choose 'Subscribe to SNS Topic.'

Obviously make a SNS topic prior to doing this. You can setup the topic to automatically send a request to a URL every time an event happens, essentially turning this into a push.

Best of luck!

Upvotes: 5

Jeff
Jeff

Reputation: 6707

The magic that lets SQS scale so well is that it offers very few features compared to other message passing systems. The user must: poll for messages; deal with messages getting delivered out of order; deal with messages getting delivered more than once; deal with occasional very large latency on message delivery (like 50 seconds).

It is great for certain tasks, and absolutely unusable for others. I for one spent far too long attempting to make it what it is not, and I really think Amazon should be more clear in their docs to warn you about not just what it is but also what is not. I ended up with RabbitMQ and couldn't be happier - but yes, there is a point at which I'll need to deal with scaling it.

Upvotes: 2

Related Questions