本文整理匯總了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)