modify alert sql
This commit is contained in:
parent
eb4a7213fd
commit
29df00a89d
|
@ -63,7 +63,7 @@ async function subscribe(consumer) {
|
|||
console.log(`data: ${key} ${value}`);
|
||||
}
|
||||
consumer.commit();
|
||||
console.log("commit offset manually successfully.");
|
||||
console.log("Commit offset manually successfully.");
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to poll data; err.code, ErrCode:" + err.code + "; ErrMessage: " + err.message);
|
||||
|
@ -80,7 +80,7 @@ async function test() {
|
|||
let consumer = await createConsumer()
|
||||
await subscribe(consumer)
|
||||
await consumer.unsubscribe();
|
||||
console.log("unsubscribe consumer successfully.");
|
||||
console.log("Consumer unsubscribed successfully.");
|
||||
}
|
||||
catch (err) {
|
||||
console.error("Failed to unsubscribe consume, ErrCode:" + err.code + "; ErrMessage: " + err.message);
|
||||
|
|
|
@ -79,20 +79,11 @@ async function test() {
|
|||
}
|
||||
|
||||
let assignment = await consumer.assignment();
|
||||
for (let i in assignment) {
|
||||
console.log("seek before:", assignment[i]);
|
||||
}
|
||||
|
||||
await consumer.seekToBeginning(assignment);
|
||||
console.log("assignment seek to beginning successfully");
|
||||
assignment = await consumer.assignment();
|
||||
for (let i in assignment) {
|
||||
console.log("seek after:", assignment[i]);
|
||||
}
|
||||
await consumer.unsubscribe();
|
||||
console.log("Assignment seek to beginning successfully");
|
||||
}
|
||||
catch (err) {
|
||||
console.error("seek example failed, ErrCode:" + err.code + "; ErrMessage: " + err.message);
|
||||
console.error("Seek example failed, ErrCode:" + err.code + "; ErrMessage: " + err.message);
|
||||
}
|
||||
finally {
|
||||
if (consumer) {
|
||||
|
|
|
@ -37,9 +37,9 @@ def prepareMeta():
|
|||
VALUES (NOW + 1a, 10.30000, 218, 0.25000)
|
||||
"""
|
||||
affectedRows = conn.execute(sql)
|
||||
print(f"inserted into {affectedRows} rows to power.meters successfully.")
|
||||
print(f"Inserted into {affectedRows} rows to power.meters successfully.")
|
||||
except Exception as err:
|
||||
print(f"prepare meta ErrMessage:{err}")
|
||||
print(f"Prepare insert data error, ErrMessage:{err}")
|
||||
raise err
|
||||
finally:
|
||||
if conn:
|
||||
|
@ -80,13 +80,13 @@ def subscribe(consumer):
|
|||
try:
|
||||
# subscribe to the topics
|
||||
consumer.subscribe(["topic_meters"])
|
||||
print("subscribe topics successfully")
|
||||
print("Subscribe topics successfully")
|
||||
for i in range(50):
|
||||
records = consumer.poll(1)
|
||||
if records:
|
||||
err = records.error()
|
||||
if err is not None:
|
||||
print(f"poll data error, {err}")
|
||||
print(f"Poll data error, {err}")
|
||||
raise err
|
||||
|
||||
val = records.value()
|
||||
|
@ -110,7 +110,7 @@ def commit_offset(consumer):
|
|||
if records:
|
||||
err = records.error()
|
||||
if err is not None:
|
||||
print(f"poll data error, {err}")
|
||||
print(f"Poll data error, {err}")
|
||||
raise err
|
||||
|
||||
val = records.value()
|
||||
|
@ -120,7 +120,7 @@ def commit_offset(consumer):
|
|||
|
||||
# after processing the data, commit the offset manually
|
||||
consumer.commit(records)
|
||||
print("commit offset manually successfully.");
|
||||
print("Commit offset manually successfully.");
|
||||
|
||||
except Exception as err:
|
||||
print(f"Failed to poll data, ErrMessage:{err}")
|
||||
|
@ -134,12 +134,11 @@ def seek_offset(consumer):
|
|||
assignments = consumer.assignment()
|
||||
if assignments:
|
||||
for partition in assignments:
|
||||
print(f"first data polled: {partition.offset}")
|
||||
partition.offset = 0
|
||||
consumer.seek(partition)
|
||||
print(f"assignment seek to beginning successfully");
|
||||
print(f"Assignment seek to beginning successfully");
|
||||
except Exception as err:
|
||||
print(f"seek example failed; ErrMessage:{err}")
|
||||
print(f"Seek example failed; ErrMessage:{err}")
|
||||
raise err
|
||||
# ANCHOR_END: assignment
|
||||
|
||||
|
@ -148,7 +147,7 @@ def seek_offset(consumer):
|
|||
def unsubscribe(consumer):
|
||||
try:
|
||||
consumer.unsubscribe()
|
||||
print("unsubscribe consumer successfully.");
|
||||
print("Consumer unsubscribed successfully.");
|
||||
except Exception as err:
|
||||
print(f"Failed to unsubscribe consumer. ErrMessage:{err}")
|
||||
|
||||
|
|
Loading…
Reference in New Issue