-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from Jargon9/master
Add README_EN.md
- Loading branch information
Showing
10 changed files
with
312 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### Prepare the client | ||
The demo aims to show you how to run an application. Refer to official documentation to configure parameters. This helps ensure the robustness of your application and the stability and performance of the client. | ||
The demo is written based on open source clients. For more information, see https://github.com/confluentinc/confluent-kafka-go. | ||
|
||
go 1.13+ | ||
|
||
### Prepare configuration files | ||
Modify the configuration in conf/kafka.json. | ||
For information about endpoints, see https://www.alibabacloud.com/help/en/message-queue-for-apache-kafka/latest/comparison-among-endpoints. | ||
Multiple topics are sent in the demo. Therefore, create at least two topics in the Message Queue for Apache Kafka console before the test. | ||
|
||
| Parameter | Description | Required | | ||
| --- | --- | --- | | ||
| topic | The name of one of the topics that you created in the Message Queue for Apache Kafka console. | Yes | | ||
| topic2 | The name of the other topic that you created in the Message Queue for Apache Kafka console. | Yes | | ||
| group.id | The ID of the consumer group that you created in the Message Queue for Apache Kafka console. | No. Consumer groups are required only by consumers. | | ||
| bootstrap.servers | The endpoint. You can obtain the endpoint on the Instance Details page in the Message Queue for Apache Kafka console. | Yes | | ||
| security.protocol | The security protocol. Default value: PLAINTEXT. Valid values: SASL_SSL and SASL_PLAINTEXT. | Yes | | ||
| sasl.mechanism | The Simple Authentication and Security Layer (SASL) mechanism. Default value: PLAIN. Valid value: SCRAM-SHA-256. | Required if SASL is included in the protocol. | | ||
| sasl.username | The username. You can obtain the username on the Instance Details page in the Message Queue for Apache Kafka console. | Required if SASL is included in the protocol. | | ||
| sasl.password | The password. You can obtain the password on the Instance Details page in the Message Queue for Apache Kafka console. | Required if SASL is included in the protocol. | | ||
|
||
### Start the test | ||
``` | ||
# Send messages | ||
go run -mod=vendor producer/producer.go | ||
# Consume messages | ||
go run -mod=vendor consumer/consumer.go | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
### Description | ||
The demo aims to show you how to run an application. Refer to official documentation to configure parameters. This helps ensure the robustness of your application and the stability and performance of the client. | ||
For more information, see [confluent-kafka-python](https://github.com/confluentinc/confluent-kafka-python) and [confluent_kafka API](https://docs.confluent.io/current/clients/confluent-kafka-python/). | ||
For information about parameter configurations, see [Configuration properties](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). | ||
|
||
#### Procedure | ||
1. For information about endpoints in setting.py, see [View endpoints](https://help.aliyun.com/document_detail/68342.html?spm=a2c4g.11186623.6.554.X2a7Ga). | ||
2. For information about topics and consumer groups, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). Then, update the resource information in setting.py. | ||
3. Configure the username and password in setting.py after you obtain them on the Instance Details page in the Message Queue for Apache Kafka console. | ||
4. pip install confluent-kafka |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### Description | ||
The demo aims to show you how to run an application. Refer to official documentation to configure parameters. This helps ensure the robustness of your application and the stability and performance of the client. | ||
For more information, see [confluent-kafka-python](https://github.com/confluentinc/confluent-kafka-python) and [confluent_kafka API](https://docs.confluent.io/current/clients/confluent-kafka-python/). | ||
|
||
#### Procedure | ||
1. For information about endpoints in setting.py, see [View endpoints](https://help.aliyun.com/document_detail/68342.html?spm=a2c4g.11186623.6.554.X2a7Ga). | ||
2. For information about topics and consumer groups, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). Then, update the resource information in setting.py. | ||
3. pip install confluent-kafka |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#### Description | ||
The demo aims to show you how to run an application. Refer to official documentation to configure parameters. This helps ensure the robustness of your application and the stability and performance of the client. | ||
For more information, see the [open source website](https://github.com/edenhill/librdkafka), [Introduction to librdkafka](https://github.com/edenhill/librdkafka/blob/master/INTRODUCTION.md#documentation), and [Configuration properties](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). | ||
|
||
#### Install dependencies for CentOS 7 | ||
1. Install GNU Compiler Collection (GCC). | ||
``` | ||
sudo yum install gcc-c++ | ||
``` | ||
|
||
2. Install Simple Authentication and Security Layer (SASL) and Secure Sockets Layer (SSL) libraries. | ||
|
||
``` | ||
yum install openssl openssl-devel | ||
yum install cyrus-sasl{,-plain} | ||
``` | ||
|
||
3. Add a YUM repository. | ||
Go to the /etc/yum.repos.d /directory and create a file named confluent.repo that contains the following content: | ||
|
||
``` | ||
[Confluent.dist] | ||
name=Confluent repository (dist) | ||
baseurl=https://packages.confluent.io/rpm/5.1/7 | ||
gpgcheck=1 | ||
gpgkey=https://packages.confluent.io/rpm/5.1/archive.key | ||
enabled=1 | ||
[Confluent] | ||
name=Confluent repository | ||
baseurl=https://packages.confluent.io/rpm/5.1 | ||
gpgcheck=1 | ||
gpgkey=https://packages.confluent.io/rpm/5.1/archive.key | ||
enabled=1 | ||
``` | ||
|
||
4. Run the installation command. | ||
``` | ||
sudo yum clean all && yum install librdkafka-devel | ||
``` | ||
|
||
|
||
|
||
#### Install dependencies for other operating systems | ||
1. Install GCC 4.8.5 or later. | ||
2. Follow the instructions on the [open source website](https://github.com/edenhill/librdkafka) to install dependencies. | ||
|
||
|
||
#### Procedure | ||
1. For information about endpoints, see [View endpoints](https://help.aliyun.com/document_detail/68342.html?spm=a2c4g.11186623.6.554.X2a7Ga). | ||
2. For information about topics and consumer groups, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | ||
3. You can obtain the username and password on the Instance Details page in the Message Queue for Apache Kafka console. | ||
4. Run the sh comple.sh command to compile the messages. | ||
5. Enter `./kafka_producer <bootstrap_servers> <topic> <username> <password>` and press Enter to send messages. | ||
6. Enter `./kafka_consumer -g <group> -b <bootstrap_servers> -u <username> -p <password> <topic>` and press Enter to consume messages. | ||
|
||
#### Test screenshots | ||
![Send and receive messages](https://img.alicdn.com/5476e8b07b923/TB1YQfgScbpK1RjSZFyXXX_qFXa) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#### Description | ||
The demo aims to show you how to run an application. Refer to official documentation to configure parameters. This helps ensure the robustness of your application and the stability and performance of the client. | ||
For more information, see the [open source website](https://github.com/edenhill/librdkafka), [Introduction to librdkafka](https://github.com/edenhill/librdkafka/blob/master/INTRODUCTION.md#documentation), and [Configuration properties](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). | ||
|
||
#### Install dependencies for CentOS 7 | ||
1. Install GNU Compiler Collection (GCC). | ||
``` | ||
sudo yum install gcc-c++ | ||
``` | ||
|
||
2. Install Simple Authentication and Security Layer (SASL) and Secure Sockets Layer (SSL) libraries. | ||
|
||
``` | ||
yum install openssl openssl-devel | ||
yum install cyrus-sasl{,-plain} | ||
``` | ||
|
||
3. Add a YUM repository. | ||
Go to the /etc/yum.repos.d /directory and create a file named confluent.repo that contains the following content: | ||
|
||
``` | ||
[Confluent.dist] | ||
name=Confluent repository (dist) | ||
baseurl=https://packages.confluent.io/rpm/5.1/7 | ||
gpgcheck=1 | ||
gpgkey=https://packages.confluent.io/rpm/5.1/archive.key | ||
enabled=1 | ||
[Confluent] | ||
name=Confluent repository | ||
baseurl=https://packages.confluent.io/rpm/5.1 | ||
gpgcheck=1 | ||
gpgkey=https://packages.confluent.io/rpm/5.1/archive.key | ||
enabled=1 | ||
``` | ||
|
||
4. Run the installation command. | ||
``` | ||
sudo yum clean all && yum install librdkafka-devel | ||
``` | ||
|
||
|
||
|
||
#### Install dependencies for other operating systems | ||
1. Install GCC 4.8.5 or later. | ||
2. Follow the instructions on the [open source website](https://github.com/edenhill/librdkafka) to install dependencies. | ||
|
||
|
||
#### Procedure | ||
1. For information about endpoints, see [View endpoints](https://help.aliyun.com/document_detail/68342.html?spm=a2c4g.11186623.6.554.X2a7Ga). | ||
2. For information about topics and consumer groups, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | ||
3. Run the sh comple.sh command to compile the messages. | ||
4. Enter `./kafka_producer <bootstrap_servers> <topic>` and press Enter to send messages. | ||
5. Enter `./kafka_consumer -g <group> -b <bootstrap_servers> <topic>` and press Enter to consume messages. | ||
|
||
#### Test screenshots | ||
![Send messages](https://img.alicdn.com/5476e8b07b923/TB1gbbVOhjaK1RjSZKzXXXVwXXa) | ||
![Consume messages](https://img.alicdn.com/5476e8b07b923/TB1V8nwOmzqK1RjSZFpXXakSXXa) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# demo | ||
Select a demo for verification based on the information of the instance that you purchased. | ||
``` | ||
├── README.md | ||
├── beta | ||
│ ├── README.md | ||
│ ├── pom.xml | ||
│ ├── run_consumer.sh | ||
│ ├── run_producer.sh | ||
│ └── src | ||
├── vpc | ||
│ ├── README.md | ||
│ ├── pom.xml | ||
│ ├── build.sh | ||
│ └── src | ||
└── vpc-ssl | ||
├── README.md | ||
├── pom.xml | ||
├── run_consumer.sh | ||
├── run_producer.sh | ||
└── src | ||
``` | ||
|
||
## beta | ||
The demo describes how public preview instances access Message Queue for Apache Kafka and is discarded. | ||
|
||
## vpc | ||
The demo describes how commercial VPC-connected instances access Message Queue for Apache Kafka by using the default endpoint. | ||
|
||
## vpc-ssl | ||
The demo describes how commercial Internet-connected instances access Message Queue for Apache Kafka by using the SSL endpoint. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
### Description | ||
The demo aims to show you how to run an application. Refer to official documentation to configure parameters. This helps ensure the robustness of your application and the stability and performance of the client. | ||
1. This demo is developed based on the open source client [node-rdkafka](https://github.com/Blizzard/node-rdkafka). | ||
2. Follow the instructions below to configure and run the demo. | ||
|
||
### Run the demo | ||
1. Make sure that the Node environment is installed. | ||
2. export LDFLAGS="-L/usr/local/opt/openssl/lib"; export CPPFLAGS="-I/usr/local/opt/openssl/include"; npm install node-rdkafka | ||
3. Follow the instructions below to configure the producer.js and consumer.js files. | ||
4. Run the node producer.js file to produce messages. | ||
5. Run the node consumer.js file to consume messages. | ||
|
||
### Configuration description | ||
|
||
##### vpc | ||
Demo for the access of VPC-connected instances | ||
|
||
| Configuration file in demo | Parameter | Description | | ||
| --- | --- | --- | | ||
| producer.js/consumer.js | topic | The name of the topic that you created in the Message Queue for Apache Kafka console. For more information, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | | ||
| producer.js/consumer.js | bootstrap.servers | The endpoint. For more information, see [View endpoints](https://help.aliyun.com/document_detail/68342.html?spm=a2c4g.11186623.6.554.X2a7Ga). | | ||
| consumer.js | group.id | The ID of the consumer group that you created in the Message Queue for Apache Kafka. For more information, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | | ||
|
||
##### vpc-ssl | ||
Note that the public bandwidth must not be too small. Otherwise, messages may fail to be read. Refer to the settings of parameters such as max.partition.fetch.bytes in consumer.js. It is recommended that the following conditions be met: | ||
|
||
* Set the max.partition.fetch.bytes parameter to a value that is greater than the size of a message. | ||
* Set the max.partition.fetch.bytes \* parameter to a value that is less than Public bandwidth/8. Unit for public bandwidth: bit/s. Unit for the parameter: bytes. | ||
|
||
|
||
Demo for the access of Internet-connected instances by using the SSL endpoint | ||
|
||
| Configuration file in demo | Parameter | Description | | ||
| --- | --- | --- | | ||
| producer.js/consumer.js | topic | The name of the topic that you created in the Message Queue for Apache Kafka console. For more information, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | | ||
| producer.js/consumer.js | bootstrap.servers | The endpoint. For more information, see [View endpoints](https://help.aliyun.com/document_detail/68342.html?spm=a2c4g.11186623.6.554.X2a7Ga). | | ||
| producer.js/consumer.js | sasl.username | The username. Use the username on the Instance Details page in the Message Queue for Apache Kafka console. | | ||
| producer.js/consumer.js | sasl.password | The password. Use the password on the Instance Details page in the Message Queue for Apache Kafka console. | | ||
| consumer.js | group.id | The ID of the group that you created in the Message Queue for Apache Kafka console. For more information, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | | ||
| producer.js/consumer.js | ssl.ca.location | The path of the root certificate. You do not need to modify the path when you run the demo. However, during actual deployment, you must change the path to the actual path. | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
### Run the demo | ||
1. Refer to the CPP demo to install the Kafka library first. | ||
2. This Demo is based on the open source client [php-rdkafka](https://github.com/arnaud-lb/php-rdkafka). Install the corresponding module based on the [installation guide](https://arnaud-lb.github.io/php-rdkafka/phpdoc/rdkafka.setup.html) first. You may need to configure php.ini after you install the module. To confirm whether the installation is successful, call php -m|grep kafka. | ||
3. Configure setting.php based on the following instructions. | ||
4. Modify other configurations in the code. Example: `$conf->set('xxx', 'xxx');`. For information about the description of the configurations, see [Configuration properties](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). | ||
5. Run the php kafka-producer.php file to send messages. | ||
6. Run the php kafka-consumer.php file to consume messages. | ||
|
||
|
||
### Configuration description | ||
|
||
| Configuration file in demo | Parameter | Description | | ||
| --- | --- | --- | | ||
| setting.php | topic_name | The name of the topic that you created in the Message Queue for Apache Kafka console. For more information, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | | ||
| setting.php | consumer_id | The ID of the consumer group that you created in the Message Queue for Apache Kafka console. For more information, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | | ||
| setting.php | bootstrap_servers | The endpoint. For more information, see [View endpoints](https://help.aliyun.com/document_detail/68342.html). | | ||
| setting.php | sasl_plain_username | The username. You can obtain the username on the Instance Details page in the Message Queue for Apache Kafka console. | | ||
| setting.php | sasl_plain_password | The password. You can obtain the password on the Instance Details page in the Message Queue for Apache Kafka console. | | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
### Run the demo | ||
1. Refer to the CPP demo to install the Kafka library first. | ||
2. This Demo is based on the open source client [php-rdkafka](https://github.com/arnaud-lb/php-rdkafka). Install the corresponding module based on the [installation guide](https://arnaud-lb.github.io/php-rdkafka/phpdoc/rdkafka.setup.html) first. You may need to configure php.ini after you install the module. To confirm whether the installation is successful, call php -m|grep kafka. | ||
3. Configure setting.php based on the following instructions. | ||
4. Modify other configurations in the code. Example: `$conf->set('xxx', 'xxx');`. For information about the description of the configurations, see [Configuration properties](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md). | ||
5. Run the php kafka-producer.php file to send messages. | ||
6. Run the php kafka-consumer.php file to consume messages. | ||
|
||
|
||
### Configuration description | ||
|
||
| Configuration file in demo | Parameter | Description | | ||
| --- | --- | --- | | ||
| setting.php | topic_name | The name of the topic that you created in the Message Queue for Apache Kafka console. For more information, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | | ||
| setting.php | consumer_id | The ID of the consumer group that you created in the Message Queue for Apache Kafka console. For more information, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | | ||
| setting.php | bootstrap_servers | The endpoint. For more information, see [View endpoints](https://help.aliyun.com/document_detail/68342.html). | | ||
| setting.php | sasl_plain_username | The username. You can obtain the username on the Instance Details page in the Message Queue for Apache Kafka console. | | ||
| setting.php | sasl_plain_password | The password. You can obtain the password on the Instance Details page in the Message Queue for Apache Kafka console. | | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
### Description | ||
The demo aims to show you how to run an application. Refer to official documentation to configure parameters. This helps ensure the robustness of your application and the stability and performance of the client. | ||
For more information, see [ruby-kafka](https://github.com/zendesk/ruby-kafka). | ||
|
||
|
||
#### Procedure | ||
1. gem install ruby-kafka -v 0.6.8 | ||
2. For information about endpoints, see [View endpoints](https://help.aliyun.com/document_detail/68342.html?spm=a2c4g.11186623.6.554.X2a7Ga). | ||
3. For information about topics and consumer groups, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | ||
|
||
#### vpc-ssl | ||
1. For information about endpoints, see [View endpoints](https://help.aliyun.com/document_detail/68342.html?spm=a2c4g.11186623.6.554.X2a7Ga). | ||
2. For information about topics and consumer groups, see [Create resources](https://help.aliyun.com/document_detail/68328.html?spm=a2c4g.11186623.6.549.xvKAt6). | ||
3. You can obtain the username and password on the Instance Details page in the Message Queue for Apache Kafka console. | ||
4. cert.pem is the certificate provided by Alibaba Cloud. |