A first test kafka message queue middleware (only suitable for beginners Kazakhstan)

Kafka a first test message queue middleware

Today bet a bit bored, and then looked at the statistics on messaging middleware, simple little understanding of Kazakhstan, said the Internet too big on the grade, literally wanted for a long time; that is, as a message notification, for example, you want to tell him you like so and so, or to a meeting, which notifies the person; can be divided into different themes, different ways to accept.


This is the first time I have hands-Ha, just look at the previous theoretical knowledge; theory we www.baidu.com some are aware of 7788 ha, my hands directly on the process.


You need to be downloaded; here Download http://kafka.apache.org/downloads ; below


Select the appropriate directory to be decompressed after downloading is completed, this case is carried out at ambient windos; below


As already download is complete, the next step is to start, and then tested;


Open your extracted files, G: \ Downloads \ 04 \ kafka_2.11-2.3.0 put this into your own path;

Enter cmd in the address bar or shift + right mouse button will do. Open a command line on behalf of the current directory;

Enter the command:. \ Bin \ windows \ zookeeper-server-start.bat \ config \ zookeeper.properties ;. represents the current directory, use the bat and start using behind Zookeeper configuration.

It appears in the following figure and there is nothing wrong on behalf of the successful launch.


Start Kafka

The same path, and then open a new command line window; enter the command: \ bin \ windows \ kafka-server-start.bat \ config \ server.properties..


Now we need to start have been started, open the command line window do not closed;

Now we need to create a theme, it is equivalent to the type of message, it called msg1

Under the file into the directory \ bin \ windows, again to open a new command line window;

输入创建主题命令:kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic msg1


现在消息的主题已经创建了

接下来创建发送消息的生产者,用于发送消息

进入的文件目录\bin\windows下,再次打开一个新的命令行窗口;

输入创建主题命令:kafka-console-producer.bat --broker-list localhost:9092 --topic msg1


最后一步创建接受消息的消费者,用于接受消息

进入的文件目录\bin\windows下,再次打开一个新的命令行窗口;

输入创建主题命令:kafka-console-producer.bat --broker-list localhost:9092 --topic msg1


最后就是测试了,我们在发送消息的窗口输入信息,在接受信息的窗口上就可以收到了;如下图:


好了,测试完毕;大家可以自行多创建几个主题多开几个窗口进行不同的主题发送试试看!

下次有时间我再整理到项目中用代码写案例了,有想一起学习了童鞋们可以加一波关注哈!!!!


Guess you like

Origin www.cnblogs.com/qq376324789/p/11316895.html