Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #9 from E-Xor/more_examples

Added a usage example
  • Loading branch information...
commit 7575e2d47401dd52df3ef726f9c414d9c1a82ed1 2 parents af7534b + fda2876
@famoseagle authored
Showing with 27 additions and 1 deletion.
  1. +27 −1 README.markdown
View
28 README.markdown
@@ -11,7 +11,7 @@ This client does not use eventmachine so no background thread necessary. As a re
There is currently no way to prevent buffering using eventmachine. Support for prefetch is still unreliable.
-## Example
+## Examples
require 'carrot'
@@ -29,6 +29,32 @@ There is currently no way to prevent buffering using eventmachine. Support for p
end
Carrot.stop
+### Using options with server and queue
+
+ require 'carrot'
+
+ c = Carrot.new
+ q = c.queue('queue_name', {
+ host: 'example.com',
+ user: 'username',
+ pass: 'passwd',
+ vhost: '/',
+ auto_delete: true
+ })
+ c.direct("name.exchange", { :durable => true })
+
+ 10.times do |num|
+ q.publish(num.to_s, {persistent: true, no_wait: false})
+ end
+
+ puts "Queued #{q.message_count} messages"
+
+ while msg = q.pop(:ack => true)
+ puts "Popping: #{msg}"
+ q.ack
+ end
+ c.stop
+
# LICENSE
Copyright (c) 2009 Amos Elliston, Geni.com; Published under The MIT License, see License
Please sign in to comment.
Something went wrong with that request. Please try again.