Skip to content
Browse files

- New examples using RabbitMQControlService in 'examples'.

- Moved 'twotp' specific examples into their own subdir of 'examples'.
- Update TODO with more ideas of what to improve next.
  • Loading branch information...
1 parent 4369fa1 commit 596ca05a120fc13c6a6682c8507d873a1cae1892 @clemesha-ooi clemesha-ooi committed May 21, 2010
View
10 TODO
@@ -1,3 +1,12 @@
+Lib
+---
+- put 'twotp' logic inside of RabbitMQControlService
+- Improve naming of RabbitMQControlService.
+
+Data
+----
+- cache polled queue/exchange/etc data.
+- only push/serve diff to clients (unless specifically ask for entire dataset)
Tests
-----
@@ -8,6 +17,7 @@ Web Interface
-------------
- separate api calls from web interface calls.
- provide full-feature web-interface in 'examples' dir.
+- see http://www.rabbitmq.com for ui
Filter types:
- With connections, first filter by vhostname, then other.
View
42 examples/list_queues.py
@@ -0,0 +1,42 @@
+from twisted.internet import reactor
+from twisted.internet.defer import inlineCallbacks, returnValue
+
+from txrabbitmq.service import RabbitMQControlService
+from twotp.node import Process, readCookie, buildNodeName
+
+
+def rabbitmqctl_client(erlang_cookie=None, nodename="txrabbitmq"):
+ cookie = readCookie() #TODO: allow passing 'erlang_cookie'
+ nodeName = buildNodeName(nodename)
+ process = Process(nodeName, cookie)
+ return RabbitMQControlService(process)
+
+@inlineCallbacks
+def list_queues():
+ client = rabbitmqctl_client()
+ allqueues = yield client.list_queues()
+ for q in allqueues["result"]:
+ print "\n ", q, "\n"
+ returnValue(allqueues["result"])
+
+
+@inlineCallbacks
+def queued_messages(queue_name):
+ """
+ Returns the number of existing messages in queue 'queue_name'.
+ Returns -1 if 'queue_name' does not exist.
+ """
+ client = rabbitmqctl_client()
+ allqueues = yield client.list_queues()
+ for q in allqueues["result"]:
+ if q[0] == queue_name:
+ print q[1]["messages"]
+ returnValue(q[1]["messages"])
+ returnValue(-1) #'queue_name' was not found.
+
+
+
+#reactor.callWhenRunning(list_queues)
+reactor.callWhenRunning(queued_messages, "stocks")
+reactor.run()
+
View
1 examples/twotp/README
@@ -0,0 +1 @@
+"Twisted OTP" (twotp) specific examples.
View
0 examples/add_user.py → examples/twotp/add_user.py
File renamed without changes.
View
0 examples/delete_user.py → examples/twotp/delete_user.py
File renamed without changes.
View
0 examples/exchange_info.py → examples/twotp/exchange_info.py
File renamed without changes.
View
0 examples/list_bindings.py → examples/twotp/list_bindings.py
File renamed without changes.
View
0 examples/queue_info.py → examples/twotp/queue_info.py
File renamed without changes.

0 comments on commit 596ca05

Please sign in to comment.
Something went wrong with that request. Please try again.