Im new to the RDM feeds and kafka in general but Ive been trying to connect to the train allocation and consist feed ive got all my credentials and ‘think’ im doing it right but to no avail can i get anything from the feed and know theres something missing which i cant put my finger on
Im using this code to try to connect
from kafka import KafkaConsumer
import json
import certifi
# =====================
# CONFIG
# =====================
BROKER = "pkc-z3p1v0.europe-west2.gcp.confluent.cloud:9092"
USERNAME = "”
PASSWORD = "”
TOPIC = "prod-1033-Passenger-Train-Allocation-and-Consist-1_0"
GROUP_ID = "allocation-test-reset-1"
AUTO_OFFSET = "earliest"
# =====================
# CONNECT
# =====================
consumer = KafkaConsumer(
bootstrap_servers=BROKER,
security_protocol="SASL_SSL",
sasl_mechanism="PLAIN",
sasl_plain_username=USERNAME,
sasl_plain_password=PASSWORD,
ssl_cafile=certifi.where(),
group_id=GROUP_ID,
auto_offset_reset=AUTO_OFFSET,
enable_auto_commit=True,
value_deserializer=lambda m: m.decode("utf-8")
)
consumer.subscribe([TOPIC])
print("Subscription object:", consumer.subscription())
print("Topics available:", consumer.topics())
print(f"Listening to topic: {TOPIC} ...")
consumer.poll(timeout_ms=1000)
parts = consumer.partitions_for_topic(TOPIC)
print("Partitions result:", parts)
# =====================
# LISTEN
# =====================
try:
for message in consumer:
print("---- New Message ----")
print(json.dumps(message.value, indent=2))
except KeyboardInterrupt:
print("Stopping Listener...")
finally:
consumer.close()