We provided a set of examples on using the latest flink-connector-pulsar
in the Flink repository. Showing the user how
to use this connector.
SimpleSource
: Consuming the message from Pulsar by using Flink'sStringSchema
.
Download and set up a standalone Pulsar locally. Read this tutorial and config the Pulsar one by one.
If you use macOS and Homebrew, you can use our pre-written Formula. Just execute these commands below.
brew tap streamnative/streamnative
## Without install OpenJDK
brew install pulsar
## With an OpenJDK provided by Homebrew
brew install pulsar --with-openjdk
After install and setup the Pulsar standalone, we need some management tools for operating on the Pulsar cluster. We prefer to use pulsarctl because it supports shell auto-completion. You can skip this section if you want to use the scripts bundled in Pulsar distribution.
Use homebrew to install pulsarctl
on the Mac operation system.
brew tap streamnative/streamnative
brew install pulsarctl
We would auto install zsh-completion and bash-completion when you use Homebrew.
Use this command to install pulsarctl
on the Linux operation system.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/streamnative/pulsarctl/master/install.sh)"
To install pulsarctl
on the Windows operation system, follow these steps:
- Download the package from here.
- Add the
pulsarctl
directory to your system PATH. - Execute
pulsarctl -h
to verify thatpulsarctl
is work.
All the code snippet shown below was using pulsarctl
. You can convert it to Pulsar scripts by reading the documentation for the Pulsar admin interface.
- Create the
sample
tenant on Pulsar.
## Mark sure you have the standalone cluster.
pulsarctl clusters list standalone
## Create tenant
pulsarctl tenants create sample --allowed-clusters="standalone"
- Create the
flink
namespace belowsample
tenant.
pulsarctl namespaces create sample/flink
- Create topic
simple-string
with 8 partition underflink
namespace.
pulsarctl topics create sample/flink/simple-string 8
Execute pulsarctl topics list sample/flink
make sure we would list a set of topics like below.
+-----------------------------------------------------+---------------+
| TOPIC NAME | PARTITIONED ? |
+-----------------------------------------------------+---------------+
| persistent://sample/flink/simple-string | Y |
| persistent://sample/flink/simple-string-partition-0 | N |
| persistent://sample/flink/simple-string-partition-1 | N |
| persistent://sample/flink/simple-string-partition-2 | N |
| persistent://sample/flink/simple-string-partition-3 | N |
| persistent://sample/flink/simple-string-partition-4 | N |
| persistent://sample/flink/simple-string-partition-5 | N |
| persistent://sample/flink/simple-string-partition-6 | N |
| persistent://sample/flink/simple-string-partition-7 | N |
+-----------------------------------------------------+---------------+
We share the IDEA run configuration in .run
directory. You can choose the example case in IDEA's Run Configuration
and execute it.