我试图创建一个简单的Python Pika SelectConnection,但似乎我无法使用on_open_回调打开连接,而且也没有从te on_open_error_回调中获得任何信息。有人能提出问题的原因吗?在
import pika
class RabbitmqTransport(object):
def __init__(self):
self._connection = None
self._channel = None
self._connect()
def on_connection_open(self):
print "connection created"
def on_connection_open_error(self):
print "connection open error"
def _connect(self):
# Setup RabbitMQ connection
credentials = pika.PlainCredentials('guest','guest')
parameters = pika.URLParameters('amqp://guest:guest@localhost:5672/%2F')
print "Creating Connection"
self._connection = pika.SelectConnection(parameters=parameters,on_open_callback=self.on_connection_open,on_open_error_callback=self.on_connection_open_error)
print self._connection.connection_state
print dir(self._connection)
print self._connection.is_open
r = RabbitmqTransport()
发现问题后,我在下面添加了一行,然后打开了连接,回调起作用了。在
相关问题 更多 >
编程相关推荐