• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python protocol.AMQClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: connectionMade

    def connectionMade(self):
        """Called when a connection has been made."""
        AMQClient.connectionMade(self)
        self.default_log_level = self.factory.log_level is not None and self.factory.log_level or self.default_log_level

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

        # Authenticate.
        try:
            yield self.start(self.factory.credentials)
        except Exception:
            logger.error("Authentication failed: {}".format(traceback.format_exc()))
            returnValue(None)

        # Authenticated!
        try:
            self.chan = yield self.channel(self.get_channel_number())
        except Exception:
            logger.error("Failed to get channel: {}".format(traceback.format_exc()))
            returnValue(None)

        # You now have a channel!
        try:
            yield self.chan.channel_open()
        except Exception:
            logger.error("Failed to open channel: {}".format(traceback.format_exc()))
            returnValue(None)

        # Mark the connection as open.
        self.connected = True
        logger.info('AMQP connection made.')

        # Now that the channel is open add any readers the user has specified.
        for consumer in self.factory.consumers:
            self.read(consumer)

        # Send any messages waiting to be sent.
        self.send()

        # Fire the factory's 'initial connect' deferred if it hasn't already
        if not self.factory.deferred.called:
            self.factory.deferred.callback(self)
开发者ID:gdoermann,项目名称:classymq,代码行数:43,代码来源:protocol.py


示例17: sendHeartbeat

 def sendHeartbeat(self):
     log.msg('sendHeartbeat')
     AMQClient.sendHeartbeat(self)
开发者ID:deldotdr,项目名称:debug-ion,代码行数:3,代码来源:amqp.py


示例18: reschedule_checkHB

 def reschedule_checkHB(self):
     log.msg('Reschedule check heartbeat')
     AMQClient.reschedule_checkHB(self)
开发者ID:deldotdr,项目名称:debug-ion,代码行数:3,代码来源:amqp.py


示例19: reschedule_sendHB

 def reschedule_sendHB(self):
     log.msg('Reschedule send heartbeat')
     AMQClient.reschedule_sendHB(self)
开发者ID:deldotdr,项目名称:debug-ion,代码行数:3,代码来源:amqp.py


示例20: connectionMade

 def connectionMade(self):
     yield AMQClient.connectionMade(self)
     log.listener("New AMQP connection made")
     yield self.setup()
     yield self.receive_loop()
开发者ID:katzj,项目名称:graphite,代码行数:5,代码来源:amqp_listener.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.BaseQuery类代码示例发布时间:2022-05-27
下一篇:
Python testutil.replace_loop函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap