Compare commits

...

3 commits

Author SHA1 Message Date
Chas Emerick
a0fb4273b2 Merge pull request #11 from dacamo76/readme-long-polling-example
Update README with long-polling usage example
2014-09-13 07:30:15 -04:00
Daniel Alberto Cañas
478210ccb2 Update README with long-polling usage example 2014-09-12 16:26:30 -06:00
Chas Emerick
e4a15227f6 [maven-release-plugin] prepare for next development iteration 2014-09-09 08:02:07 -04:00
2 changed files with 23 additions and 1 deletions

View file

@ -108,6 +108,28 @@ That's cleaner than having to interop directly with the Java SDK, but it's all
pretty pedestrian stuff. You can do more interesting things with some
simple higher-order functions and other nifty Clojure facilities.
### Enabling SQS Long Polling
[Long polling](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.html) reduces the number of empty responses by allowing Amazon SQS service to wait until a message is available in the queue before sending a response. You can enable long polling on an individual receive request by supplying the optional kwarg `:wait-time-seconds`:
:wait-time-seconds - time in seconds (bewteen 0 and 20) for SQS to wait if there are no messages in the queue. A value of 0 indicates no long polling.
```clojure
; ensure our queue is empty to start
#> (get (sqs/queue-attrs client q) "ApproximateNumberOfMessages")
"0"
#> (let [no-polling (future (sqs/receive client q))
long-polling (future (sqs/receive client q :wait-time-seconds 20))]
(Thread/sleep 10000) ;; Sleep 10s before sending message
(sqs/send client q "my message body")
(println (count @no-polling))
(println (count @long-polling)))
0
1
nil
```
### Sending and receiving Clojure values
SQS' message bodies are strings, so you can stuff anything in them that you can

View file

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.cemerick</groupId>
<artifactId>bandalore</artifactId>
<version>0.0.6</version>
<version>0.0.7-SNAPSHOT</version>
<name>bandalore</name>
<description>A Clojure library for Amazon's Simple Queue Service (SQS).</description>
<url>http://github.com/cemerick/bandalore</url>