MCPcopy Create free account
hub / github.com/decodableco/examples / Consumer

Class Consumer

osquery/consumer.py:5–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import pulsar,time,sys
4
5class Consumer:
6
7 def __init__(self, service_url, topic, token, consumer):
8 self.client = pulsar.Client(service_url, authentication=pulsar.AuthenticationToken(token))
9 self.consumer = self.client.subscribe(topic, consumer)
10
11 def consume(self):
12 waitingForMsg = True
13 while waitingForMsg:
14 try:
15 msg = self.consumer.receive(2000)
16 print("Received message '{}' id='{}'".format(msg.data(), msg.message_id()))
17 self.consumer.acknowledge(msg)
18
19 # waitingForMsg = False
20 except:
21 time.sleep(1)
22 continue
23
24
25 def __del__(self):
26 self.client.close()
27
28
29

Callers 1

consumer.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected