本文共 2020 字,大约阅读时间需要 6 分钟。
[zk: 127.0.0.1:2181(CONNECTED) 2] create /test "hello" Created /test [zk: 127.0.0.1:2181(CONNECTED) 3] get /test "hello" cZxid = 0x8 ctime = Wed Dec 28 10:03:24 CST 2016 mZxid = 0x8 mtime = Wed Dec 28 10:03:24 CST 2016 pZxid = 0x8 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 7 numChildren = 0 |
Step 4: Send some messages Kafka comes with a command line client that will take input from a file or from standard input and send it out as messages to the Kafka cluster. By default, each line will be sent as a separate message. Run the producer and then type a few messages into the console to send to the server. > bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test This is a message This is another message Step 5: Start a consumer Kafka also has a command line consumer that will dump out messages to standard output. > bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning This is a message This is another message If you have each of the above commands running in a different terminal then you should now be able to type messages into the producer terminal and see them appear in the consumer terminal. All of the command line tools have additional options; running the command with no arguments will display usage information documenting them in more detail. |
转载地址:http://iflbi.baihongyu.com/