From 4515b8f6f5e3548884828eb8d96ac750e37821e3 Mon Sep 17 00:00:00 2001 From: Benjamin Diaz Date: Fri, 6 Jul 2018 12:03:35 -0300 Subject: [PATCH] [PM] Adds group-id to Kafka consumer in agent Fixes CPU spikes during OSM startup Signed-off-by: Benjamin Diaz --- policy_module/osm_policy_module/core/agent.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/policy_module/osm_policy_module/core/agent.py b/policy_module/osm_policy_module/core/agent.py index 3a3b20c..cdd5dfc 100644 --- a/policy_module/osm_policy_module/core/agent.py +++ b/policy_module/osm_policy_module/core/agent.py @@ -45,11 +45,10 @@ class PolicyModuleAgent: # Initialize Kafka consumer log.info("Connecting to Kafka server at %s", kafka_server) - # TODO: Add logic to handle deduplication of messages when using group_id. - # See: https://stackoverflow.com/a/29836412 consumer = KafkaConsumer(bootstrap_servers=kafka_server, key_deserializer=bytes.decode, - value_deserializer=bytes.decode) + value_deserializer=bytes.decode, + group_id="pm-consumer") consumer.subscribe(['lcm_pm', 'alarm_response']) for message in consumer: -- 2.25.1