本文整理汇总了Python中stompest.Stomp.add方法的典型用法代码示例。如果您正苦于以下问题:Python Stomp.add方法的具体用法?Python Stomp.add怎么用?Python Stomp.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stompest.Stomp
的用法示例。
在下文中一共展示了Stomp.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import add [as 别名]
def run(self, _):
client = Stomp(self.config)
yield client.connect()
client.add(ReceiptListener(1.0))
for j in range(10):
yield client.send(self.QUEUE, json.dumps({'count': j}).encode(), receipt='message-%d' % j)
client.disconnect(receipt='bye')
yield client.disconnected # graceful disconnect: waits until all receipts have arrived
示例2: run
# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import add [as 别名]
def run(self):
''' Initializes the stompest async client '''
queue_url = self.config['queue']['url']
queue_name = self.config['queue']['name']
error_queue_name = self.config['queue']['error_name']
client = Stomp(StompConfig(queue_url))
yield client.connect()
client.subscribe(
queue_name, # must begin with leading slash (eg: /queue/)
headers={StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL},
listener=SubscriptionListener(
self.consume,
errorDestination=error_queue_name
)
)
client.add(self)