当前位置: 首页>>代码示例>>Python>>正文


Python protocol.AMQClient类代码示例

本文整理汇总了Python中txamqp.protocol.AMQClient的典型用法代码示例。如果您正苦于以下问题:Python AMQClient类的具体用法?Python AMQClient怎么用?Python AMQClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AMQClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, *args, **kwargs):
     print 'init protocol'
     self._stop = False
     # callback on authenticated
     self._auth_succ = Deferred()
     # callback on read_channel opened
     self._read_opened = Deferred()
     # callback on write_channel opened
     self._write_opened = Deferred()
     # callback on read_loop started
     self._read_loop_started = Deferred()
     # callback on shutdown read loop
     self._read_loop_down = Deferred()
     # read queue timeout
     self.q_timeout = 1
     # read loop call
     self._rloop_call = None
     self._sloop_call = None
     self.read_queue = None
     self.read_chan = None
     kwargs['heartbeat'] = kwargs.get('heartbeat', 10)
     # failure traps
     #self.log.warning('AUTO SHUTDOWN 15 sec')
     #reactor.callLater(15, lambda _: self.shutdown_protocol(), (None,))
     self.__messages = set()
     AMQClient.__init__(self, *args, **kwargs)
开发者ID:winshuai,项目名称:txamqp_ext,代码行数:26,代码来源:protocol.py

示例2: connectionMade

    def connectionMade(self):
        """
        Hook called when the connection is made; we'll use this to perform
        exchange setup, etc.
        """
        try:
            connectionInfo = self.factory.connectionInfo
            set_keepalive(self.transport.socket, connectionInfo.amqpconnectionheartbeat)
            AMQClient.connectionMade(self)
            log.debug('Made initial connection to message broker')
            self._connected = False
            # Authenticate
            try:
                yield self.start({'LOGIN':connectionInfo.user, 'PASSWORD':connectionInfo.password})
                self.factory.onAuthenticated(True)
                log.debug('Successfully authenticated as %s' % connectionInfo.user)
            except Exception as e:
                log.warn("Error authenticating to %s as %s" % (connectionInfo.host, connectionInfo.user))
                self.factory.onAuthenticated(e.args[0])
                return
            # Get a channel
            self.chan = yield self.get_channel()
            self._connected = True
            # Initialize the queues
            yield self.begin_listening()

            # Call back our deferred
            self.factory.onConnectionMade(self)
            # Flush any messages that have been sent before now
            yield self.send()
            returnValue(None)
        except Exception:
            log.exception("Unable to connect")
开发者ID:jhanson,项目名称:zenoss-protocols,代码行数:33,代码来源:amqp.py

示例3: __init__

 def __init__(self, *args, **kwargs):
     self.log.debug('init protocol')
     self._stop = False
     # callback on authenticated
     self._auth_succ = Deferred()
     # callback on read_channel opened
     self._read_opened = Deferred()
     # callback on write_channel opened
     self._write_opened = Deferred()
     # callback on read_loop started
     self._read_loop_started = Deferred()
     # callback on shutdown read loop
     self._read_loop_down = Deferred()
     # read queue timeout
     self.q_timeout = 1
     # read loop call
     self._rloop_call = None
     self._sloop_call = None
     # ensure that we start read loop only once
     self._read_loop_enabled = False
     self.read_queue = None
     self.read_chan = None
     kwargs['heartbeat'] = kwargs.get('heartbeat', 10)
     self.__messages = set()
     AMQClient.__init__(self, *args, **kwargs)
开发者ID:cybergrind,项目名称:txamqp_ext,代码行数:25,代码来源:protocol.py

示例4: connectionMade

 def connectionMade(self):
     AMQClient.connectionMade(self)
     # Authenticate.
     assert self.factory is not None
     deferred = self.start({"LOGIN": self.factory.user,
                            "PASSWORD": self.factory.password})
     deferred.addCallbacks(self._authenticated, self._authentication_failed)
开发者ID:vigilo,项目名称:connector,代码行数:7,代码来源:amqp.py

示例5: AMQFactory

class AMQFactory(protocol.ReconnectingClientFactory):
    VHOST = '/'

    def __init__(self, creds):
        self.spec = txamqp.spec.load(SPECFILE)
        self.creds = creds
        self.client = None
        self.channel  = None

    def buildProtocol(self, addr):
        self.resetDelay()
        delegate = TwistedDelegate()
        self.client = AMQClient(delegate=delegate, vhost=self.VHOST, spec=self.spec)
        self.client.start(self.creds)
        return self.client

    @defer.inlineCallbacks
    def publish(self, exchange, msg, routing_key):
        if not self.client:
            raise NotImplementedError
        if not self.channel:
            yield self._createChannel()
        content = Content(msg)
        yield self.channel.basic_publish(exchange=exchange, content=content, routing_key=routing_key)

    @defer.inlineCallbacks
    def _createChannel(self):
        self.channel = yield self.client.channel(1)
        yield self.channel.channel_open()
开发者ID:ivaxer,项目名称:tippresence,代码行数:29,代码来源:publisher.py

示例6: connectionMade

 def connectionMade(self):
     AMQClient.connectionMade(self)
     yield self.authenticate(self.vumi_options['username'],
                             self.vumi_options['password'])
     # authentication was successful
     log.msg("Got an authenticated connection")
     yield self.connected_callback(self)
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:7,代码来源:service.py

示例7: makeConnection

 def makeConnection(self, transport):
     '''
     This only for debug errors
     '''
     try:
         AMQClient.makeConnection(self, transport)
     except Exception, mess:
         self.log.error('During makeConnection: %r'%mess)
开发者ID:cybergrind,项目名称:txamqp_ext,代码行数:8,代码来源:protocol.py

示例8: connectionLost

 def connectionLost(self, reason):
     """
     Remove this protocol as a consumer of log events.
     """
     self.chan = None
     self.dispatcher.unregister(self.producer.put)
     log.err(reason, "Connection lost")
     AMQClient.connectionLost(self, reason)
开发者ID:mailgun,项目名称:udplog,代码行数:8,代码来源:rabbitmq.py

示例9: connectionMade

 def connectionMade(self):
     """Called when a connection has been made."""
     AMQClient.connectionMade(self)
     # Flag that this protocol is not connected yet.
     self.connected = False
     
     # Authenticate.
     deferred = self.authenticate(self.factory.user, self.factory.password)
     deferred.addCallback(self._authenticated)
     deferred.addErrback(self._authentication_failed)
开发者ID:sanyaade,项目名称:carrot,代码行数:10,代码来源:amqp.py

示例10: connectionMade

 def connectionMade(self):
     AMQClient.connectionMade(self)
     # set that we are not connected
     # since we should authenticate and open channels
     self.connected = False
     self.log.debug('go authentication %r'%self.factory.user)
     d = self.authenticate(self.factory.user, self.factory.password)
     d.addCallback(self._authenticated)
     d.addErrback(self._error)
     return d
开发者ID:cybergrind,项目名称:txamqp_ext,代码行数:10,代码来源:protocol.py

示例11: __init__

    def __init__(self, *args, **kwargs):
        AMQClient.__init__(self, *args, **kwargs)

        if self.check_0_8():
            self.replyToField = "reply to"
        else:
            self.replyToField = "reply-to"

        self.thriftBasicReturnQueueLock = defer.DeferredLock()
        self.thriftBasicReturnQueues = {}
开发者ID:archsh,项目名称:txamqp,代码行数:10,代码来源:protocol.py

示例12: connectionMade

 def connectionMade(self):
     """
     authenticate and start the Node 
     """
     AMQClient.connectionMade(self)
     username = self.factory.username
     password = self.factory.password
     # authentication should happen automatically, and fail asap
     # XXX need to know how it can fail still
     d = self.authenticate(username, password)
     d.addCallback(self._auth_result)
     d.addErrback(self._auth_fail)
开发者ID:deldotdr,项目名称:anion,代码行数:12,代码来源:messaging.py

示例13: connectionMade

    def connectionMade(self):
        """
        Add this protocol as a consumer of log events.
        """
        AMQClient.connectionMade(self)

        def eb(failure):
            log.err(failure)
            self.transport.loseConnection()

        d = self.gotConnection()
        d.addErrback(eb)
开发者ID:mailgun,项目名称:udplog,代码行数:12,代码来源:rabbitmq.py

示例14: connectionMade

    def connectionMade(self):
        """Called when a connection has been made."""
        AMQClient.connectionMade(self)

        # Flag that this protocol is not connected yet.
        self.connected = False

        self.consumer_tags = {}

        # Authenticate.
        deferred = self.start({"LOGIN": self.factory.user, "PASSWORD": self.factory.password})
        deferred.addCallback(self._authenticated)
        deferred.addErrback(self._authentication_failed)
开发者ID:BlocklandGlass-Archive,项目名称:Glass-PyServer,代码行数:13,代码来源:amqp_helpers.py

示例15: __init__

    def __init__(self, dispatcher, username='guest', password='guest',
                       vhost='/', exchange='logs', queueSize=None):
        self.dispatcher = dispatcher
        self.username = username
        self.password = password
        self.exchange = exchange
        self.queueSize = queueSize

        self.chan = None

        specDir = FilePath(__file__).parent()
        specFilePath = specDir.child('amqp0-9-1.extended.xml')
        spec = txamqp.spec.load(specFilePath.path)

        delegate = TwistedDelegate()
        AMQClient.__init__(self, delegate=delegate, vhost=vhost,
                                 spec=spec)
开发者ID:mailgun,项目名称:udplog,代码行数:17,代码来源:rabbitmq.py


注:本文中的txamqp.protocol.AMQClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。