Windows IntelliJ Idea builds Kafka source environment

Source: Internet
Author: User

In the Kafka core principle of information, there are many online, but if you do not study its source code, always know it but do not know why. Here's how to compile the Kafka source code in the Windows environment, and build the Kafka source environment through the IntelliJ Idea development tool to facilitate local debug debugging to study Kafka's internal implementation mechanism.

Specific steps:

(1) Install JDK, version 1.8.0_131, configure Java_home:

(2) Install Scala, version 2.10.6, Configuration scala_home:

(3) Install Gradle, version 3.1, configure Gradle_home:

(4) Install MAVEN, version 3.2.1, configure Maven_home:

(5) Installation of zookeeper, version 3.4.6

Download the compressed package to zookeeper official website, unzip to any disk directory of Windows, copy the ZOO_SAMPLE.CFG under the Conf directory, change its name to Zoo.cfg, then open, specify datadir=d:\\java\\ Zookeeper-data\\3.4.6-data, for example, my configuration is as follows:

#The number of milliseconds of each tickticktime=2000#The number of ticks that initial#synchronization phase can takeinitlimit=10#The number of ticks that can pass between#sending a request and getting an acknowledgementSynclimit=5#The directory where the snapshot is stored.#Don't use/tmp for storage,/tmp here's just#example sakes.Datadir=d:\\java\\zookeeper-data\\3.4.6-data#The port at which the clients would connectclientport=2181#The maximum number of client connections.#increase this if you need to handle more clients#maxclientcnxns=60##Be sure to read the Maintenance section of the#Administrator Guide before turning on Autopurge.##http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance##The number of snapshots to retain in DataDir#autopurge.snapretaincount=3#Purge task interval in hours#Set to ' 0 ' to disable Auto Purge feature#autopurge.purgeinterval=1

Then double-click Zkserver.cmd under the Bin directory to start zookeeper:

Zookeeper after startup, for example, the default port number is 2181:

(6) Download Kafka source code. Download the source package from Kafka official website Kafka-0.10.0.1-src.tgz, unzip, for example, I extracted to the D:\KAFKA-0.10.0.1-SRC directory, under the extracted directory under the command Line window to execute the gradle idea command, Then after a long wait, the console will appear to build a successful prompt, indicating that the Kafka source code compilation completed;

(7) The development tool uses INTELLJ idea 14.1.7 (other higher versions can also be used):

(8) Install the Scala plugin in IntelliJ idea, where I installed the plugin version 1.5.4:

(9) Import the compiled Kafka source into the idea development tool, after the import directory situation:

(10) Copy the log4j.properties file under Config directory to the core\src\main\scala\ directory for easy viewing of the log:

(11) Modify the Log.dirs=d:\\tmp\\kafka-logs in the Server.properties file (modify to your own Windows disk directory)

(12) Start the Kafka server, that is, run the main method in Core\src\main\scala\kafka\kafka.scala, specify the startup parameters before running:

(13) Start the producer, start the parameter configuration:

(14) Start the consumer, start the parameter configuration:

(15) Enter the message "Hello Kafka" on the producer's console and press ENTER:

Observe the consumer's console, if there is a message to be consumed, indicating that the source environment was built successfully:

To this, Kafka in IntelliJ idea in the source environment to build success.

Windows IntelliJ Idea builds Kafka source environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.