You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/hdinsight/kafka/apache-kafka-producer-consumer-api.md
+11-27Lines changed: 11 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,21 +29,20 @@ For more information on the APIs, see Apache documentation on the [Producer API]
29
29
30
30
## Prerequisites
31
31
32
-
* Apache Kafka on HDInsight 3.6. To learn how to create a Kafka on HDInsight cluster, see [Start with Apache Kafka on HDInsight](apache-kafka-get-started.md).
33
-
32
+
* Apache Kafka on HDInsight cluster. To learn how to create the cluster, see [Start with Apache Kafka on HDInsight](apache-kafka-get-started.md).
34
33
*[Java Developer Kit (JDK) version 8](https://aka.ms/azure-jdks) or an equivalent, such as OpenJDK.
35
-
36
34
*[Apache Maven](https://maven.apache.org/download.cgi) properly [installed](https://maven.apache.org/install.html) according to Apache. Maven is a project build system for Java projects.
37
-
38
-
* An SSH client. For more information, see [Connect to HDInsight (Apache Hadoop) using SSH](../hdinsight-hadoop-linux-use-ssh-unix.md).
35
+
* An SSH client like Putty. For more information, see [Connect to HDInsight (Apache Hadoop) using SSH](../hdinsight-hadoop-linux-use-ssh-unix.md).
39
36
40
37
## Understand the code
41
38
42
-
The example application is located at [https://github.com/Azure-Samples/hdinsight-kafka-java-get-started](https://github.com/Azure-Samples/hdinsight-kafka-java-get-started), in the `Producer-Consumer` subdirectory. The application consists primarily of four files:
39
+
The example application is located at [https://github.com/Azure-Samples/hdinsight-kafka-java-get-started](https://github.com/Azure-Samples/hdinsight-kafka-java-get-started), in the `Producer-Consumer` subdirectory. If you're using **Enterprise Security Package (ESP)** enabled Kafka cluster, you should use the application version located in the `DomainJoined-Producer-Consumer` subdirectory.
43
40
41
+
The application consists primarily of four files:
44
42
*`pom.xml`: This file defines the project dependencies, Java version, and packaging methods.
45
43
*`Producer.java`: This file sends random sentences to Kafka using the producer API.
46
44
*`Consumer.java`: This file uses the consumer API to read data from Kafka and emit it to STDOUT.
45
+
*`AdminClientWrapper.java`: This file uses the admin API to create, describe, and delete Kafka topics.
47
46
*`Run.java`: The command-line interface used to run the producer and consumer code.
48
47
49
48
### Pom.xml
@@ -112,9 +111,11 @@ The [Run.java](https://github.com/Azure-Samples/hdinsight-kafka-java-get-started
112
111
113
112
## Build and deploy the example
114
113
114
+
If you would like to skip this step, prebuilt jars can be downloaded from the `Prebuilt-Jars` subdirectory. Download the kafka-producer-consumer.jar. If your cluster is **Enterprise Security Package (ESP)** enabled, use kafka-producer-consumer-esp.jar. Execute step 3 to copy the jar to your HDInsight cluster.
115
+
115
116
1. Download and extract the examples from [https://github.com/Azure-Samples/hdinsight-kafka-java-get-started](https://github.com/Azure-Samples/hdinsight-kafka-java-get-started).
116
117
117
-
2. Set your current directory to the location of the `hdinsight-kafka-java-get-started\Producer-Consumer` directory and use the following command:
118
+
2. Set your current directory to the location of the `hdinsight-kafka-java-get-started\Producer-Consumer` directory. If you are using **Enterprise Security Package (ESP)** enabled Kafka cluster, you should set the location to `DomainJoined-Producer-Consumer`subdirectory. Use the following command to build the application:
118
119
119
120
```cmd
120
121
mvn clean package
@@ -136,29 +137,12 @@ The [Run.java](https://github.com/Azure-Samples/hdinsight-kafka-java-get-started
1. Install [jq](https://stedolan.github.io/jq/), a command-line JSON processor. From the open SSH connection, enter following command to install `jq`:
140
+
1. To get the Kafka broker hosts, substitute the values for `<clustername>` and `<password>` in the following command and execute it. Use the same casing for `<clustername>` as shown in the Azure portal. Replace `<password>` with the cluster login password, then execute:
140
141
141
142
```bash
142
143
sudo apt -y install jq
143
-
```
144
-
145
-
1. Set up password variable. Replace `PASSWORD` with the cluster login password, then enter the command:
146
-
147
-
```bash
148
-
export password='PASSWORD'
149
-
```
150
-
151
-
1. Extract correctly cased cluster name. The actual casing of the cluster name may be different than you expect, depending on how the cluster was created. This command will obtain the actual casing, and then store it in a variable. Enter the following command:
> If you're doing this process from outside the cluster, there is a different procedure for storing the cluster name. Get the cluster name in lower case from the Azure portal. Then, substitute the cluster name for `<clustername>` in the following command and execute it: `export clusterName='<clustername>'`.
158
-
159
-
1. To get the Kafka broker hosts, use the following command:
0 commit comments