def __init__(self, cb):
super(RabbitMQEventSource, self).__init__()
self.daemon = True
self._closing = False
self._connection = None
self._channel = None
self._closing = False
self._consumer_tag = None
self._auto_ack = True
self._consuming = False
self._cb = cb
creds = cb.credentials
if not creds.rabbitmq_pass:
error_text = "RabbitMQEventSource requires credentials for the event bus. Make sure that\n" + \
"rabbitmq_pass, rabbitmq_user, rabbitmq_host, and rabbitmq_port are defined\n" + \
"in the credential file"
if cb.credential_profile_name:
error_text += " for profile '{0}'.".format(cb.credential_profile_name)
raise CredentialError(error_text)
self._url = "amqp://{0}:{1}@{2}:{3}".format(creds.rabbitmq_user, creds.rabbitmq_pass, creds.rabbitmq_host,
creds.rabbitmq_port)
self.QUEUE = "cbapi-event-handler-{0}-{1}".format(platform.uname()[1], os.getpid())
self.EXCHANGE = "api.events"
self.ROUTING_KEYS = registry.event_types
self.EXCHANGE_TYPE = "topic"
评论列表
文章目录