My goal is to get data from non-file sources (i.e. generated within a program or sent though an API) and have it sent to a spark stream. To accomplish this, I'm sending the data through a python-based KafkaProducer
:
$ bin/zookeeper-server-start.sh config/zookeeper.properties &
$ bin/kafka-server-start.sh config/server.properties &
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic my-topic
$ python
Python 3.6.1| Anaconda custom (64-bit)
> from kafka import KafkaProducer
> import time
> producer = KafkaProducer(bootstrap_servers='localhost:9092', value_serializer=lambda v: json.dumps(v).encode('utf-8'))
> producer.send(topic = 'my-topic', value = 'MESSAGE ACKNOWLEDGED', timestamp_ms = time.time())
> producer.close()
> exit()
My issue is that nothing appears when checking the topic from the consumer shell script:
$ bin/kafka-console-consumer.sh --bootstrap-server localhost:2181 --topic my-topic
^C$
Is something missing or wrong here? I'm new to spark/kafka/messaging systems, so anything will help. The Kafka version is 0.11.0.0 (Scala 2.11) and no changes are made to the config files.