Compare commits
3 commits
bandalore-
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0fb4273b2 | ||
|
|
478210ccb2 | ||
|
|
e4a15227f6 |
2 changed files with 23 additions and 1 deletions
22
README.md
22
README.md
|
|
@ -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
|
pretty pedestrian stuff. You can do more interesting things with some
|
||||||
simple higher-order functions and other nifty Clojure facilities.
|
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
|
### Sending and receiving Clojure values
|
||||||
|
|
||||||
SQS' message bodies are strings, so you can stuff anything in them that you can
|
SQS' message bodies are strings, so you can stuff anything in them that you can
|
||||||
|
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -2,7 +2,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.cemerick</groupId>
|
<groupId>com.cemerick</groupId>
|
||||||
<artifactId>bandalore</artifactId>
|
<artifactId>bandalore</artifactId>
|
||||||
<version>0.0.6</version>
|
<version>0.0.7-SNAPSHOT</version>
|
||||||
<name>bandalore</name>
|
<name>bandalore</name>
|
||||||
<description>A Clojure library for Amazon's Simple Queue Service (SQS).</description>
|
<description>A Clojure library for Amazon's Simple Queue Service (SQS).</description>
|
||||||
<url>http://github.com/cemerick/bandalore</url>
|
<url>http://github.com/cemerick/bandalore</url>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue