update
This commit is contained in:
parent
9cbda277fb
commit
1c16423a98
@ -113,6 +113,14 @@ async def baidu_sms_kafka_consumer(ns={}):
|
|||||||
'fetch.message.max.bytes': '1024*512',
|
'fetch.message.max.bytes': '1024*512',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# 创建日志文件
|
||||||
|
files = "baidu_kafka_msg.txt"
|
||||||
|
if not os.path.exists(filename):
|
||||||
|
with open(filename, 'w', encoding='utf-8') as f: # 'w' 模式会覆盖已有文件,但检查后使用是安全的
|
||||||
|
pass # 创建空文件
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
# 订阅的主题名称
|
# 订阅的主题名称
|
||||||
consumer.subscribe(['kaiyuanyun_msg_topic'])
|
consumer.subscribe(['kaiyuanyun_msg_topic'])
|
||||||
while True:
|
while True:
|
||||||
@ -124,6 +132,9 @@ async def baidu_sms_kafka_consumer(ns={}):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
with open('baidu_kafka_msg.txt', 'a', encoding='utf-8') as f:
|
||||||
|
f.write(f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}-{msg.value().decode('utf-8')}\n")
|
||||||
|
|
||||||
# print('Received message: {}'.format(msg.value().decode('utf-8')))
|
# print('Received message: {}'.format(msg.value().decode('utf-8')))
|
||||||
method = "POST"
|
method = "POST"
|
||||||
url = 'https://www.opencomputing.cn/baiduc/baidu_sms_kafka_consumer.dspy'
|
url = 'https://www.opencomputing.cn/baiduc/baidu_sms_kafka_consumer.dspy'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user