Skip to content

Instantly share code, notes, and snippets.

@ssorj
Created October 18, 2016 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssorj/1ccf4d1499563722bc419f1e1fac11bf to your computer and use it in GitHub Desktop.
Save ssorj/1ccf4d1499563722bc419f1e1fac11bf to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import with_statement
from proton import Message
from proton.handlers import MessagingHandler
from proton.reactor import Container
class Handler(MessagingHandler):
def on_start(self, event):
self.conn = event.container.connect("localhost:5672")
self.sent = 0
event.container.schedule(1, self)
def on_timer_task(self, event):
self.sender_1 = event.container.create_sender(self.conn, "simple_queue")
def on_sendable(self, event):
if self.sent < 10:
print(event, event.sender.name)
event.sender.send(Message("AAA"))
self.sent += 1
else:
print('on_sendable() called, but no message sent')
def on_accepted(self, event):
return
container = Container(Handler())
container.run()
---
[jross@localhost ~]$ qpidd --auth no &
2016-10-18 13:49:25 [Broker] notice Broker (pid=30659) start-up
2016-10-18 13:49:25 [Security] notice SSL plugin not enabled, you must set --ssl-cert-db to enable it.
2016-10-18 13:49:25 [Broker] notice SASL disabled: No Authentication Performed
2016-10-18 13:49:25 [Network] notice Listening on TCP/TCP6 port 5672
[jross@localhost ~]$ qpid-config add queue simple_queue
[jross@localhost ~]$ python test.py
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2e890 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2ec50 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2ec90 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2e890 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2ec50 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2ec90 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2e890 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2ec50 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2ec90 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
PN_LINK_FLOW(<proton.Sender 0x7f7b67f2e890 ~ 0x559567d2fee0>) 934e3386-b155-48c2-98f9-47bc1b4210cf-simple_queue
on_sendable() called, but no message sent
on_sendable() called, but no message sent <----- Stalls here
^CTraceback (most recent call last):
File "test3.py", line 33, in <module>
container.run()
File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 133, in run
while self.process(): pass
File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 159, in process
self._check_errors()
File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 155, in _check_errors
_compat.raise_(exc, value, tb)
File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 4022, in dispatch
ev.dispatch(self.handler)
File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3931, in dispatch
result = dispatch(handler, type.method, self)
File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3814, in dispatch
return handler.on_unhandled(method, *args)
File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 514, in on_unhandled
event.dispatch(self.base)
File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3929, in dispatch
pn_handler_dispatch(handler._impl, self._impl, type.number)
KeyboardInterrupt
[jross@localhost ~]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment