Skip to content

Commit

Permalink
Add document for pulsar IO netty (apache#5077)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuteng authored and jiazhai committed Sep 1, 2019
1 parent f1eae9c commit 1565e4e
Showing 1 changed file with 127 additions and 0 deletions.
127 changes: 127 additions & 0 deletions site2/docs/io-netty.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,130 @@ Otherwise, if the connector is running in process or thread mode, the instances
| `host` | `false` | `127.0.0.1` | The host name or address that the source instance to listen on. |
| `port` | `false` | `10999` | The port that the source instance to listen on. |
| `numberOfThreads` | `false` | `1` | The number of threads of Netty Tcp Server to accept incoming connections and handle the traffic of the accepted connections. |


### Configuration Example

Here is a configuration Json example:

```$json
{
"type": "tcp",
"host": "127.0.0.1",
"port": "10911",
"numberOfThreads": "5"
}
```
Here is a configuration Yaml example:

```$yaml
configs:
type: "tcp"
host: "127.0.0.1"
port: 10999
numberOfThreads: 1
```

### Usage example


- Start pulsar standalone

```$bash
docker pull apachepulsar/pulsar:2.4.0
docker run -d -it -p 6650:6650 -p 8080:8080 -v $PWD/data:/pulsar/data --name pulsar-netty-standalone apachepulsar/pulsar:2.4.0 bin/pulsar standalone
```

- Start pulsar-io in standalone

#### Tcp example

- Config file netty-source-config.yaml

```$yaml
configs:
type: "tcp"
host: "127.0.0.1"
port: 10999
numberOfThreads: 1
```

- Copy configuration file to pulsar server

```$bash
docker cp netty-source-config.yaml pulsar-netty-standalone:/pulsar/conf/
```

- Download netty connector and start netty connector

```$bash
docker exec -it pulsar-netty-standalone /bin/bash
curl -O http://mirror-hk.koddos.net/apache/pulsar/pulsar-2.4.0/connectors/pulsar-io-netty-2.4.0.nar
./bin/pulsar-admin sources localrun --archive pulsar-io-{{pulsar:version}}.nar --tenant public --namespace default --name netty --destination-topic-name netty-topic --source-config-file netty-source-config.yaml --parallelism 1
```

- Consume data

```$bash
docker exec -it pulsar-netty-standalone /bin/bash
./bin/pulsar-client consume -t Exclusive -s netty-sub netty-topic -n 0
```

- Open another window for send data to netty source

```$bash
docker exec -it pulsar-netty-standalone /bin/bash
apt-get update
apt-get -y install telnet
root@1d19327b2c67:/pulsar# telnet 127.0.0.1 10999
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
hello
world
```

- Verification results

In the consumer window just opened, you can see the following data

```bash
----- got message -----
hello

----- got message -----
world
```

#### Http example

- Config file netty-source-config.yaml

```$yaml
configs:
type: "http"
host: "127.0.0.1"
port: 10999
numberOfThreads: 1
```
- Start netty source

```$bash
docker exec -it pulsar-netty-standalone /bin/bash
./bin/pulsar-admin sources localrun --archive pulsar-io-{{pulsar:version}}.nar --tenant public --namespace default --name netty --destination-topic-name netty-topic --source-config-file netty-source-config.yaml --parallelism 1
```

- Verification results

```bash
curl -X POST --data 'hello, world!' http://127.0.0.1:10999/
```

- Verification results

In the consumer window just opened, you can see the following data

```bash
----- got message -----
hello, world!
```

0 comments on commit 1565e4e

Please sign in to comment.