bin/connect-standalone.sh config/connect-standalone.properties config/connect-file-source.properties config/connect-file-sink.properties
connect-file-source.properties:vim
name=local-file-source connector.class=FileStreamSource tasks.max=1 file=test.txt topic=connect-test
connect-file-sink.propertiescode
name=local-file-sink connector.class=FileStreamSink tasks.max=1 file=test.sink.txt topics=connect-test
上面命令,建立了兩個connect,一個從test.txt讀取數據到名爲connect-test的topic,另外一個從connect-test讀取數據寫入到test.sink.txt。其中test.txt和test.sink.txt文件都在kafka的安裝目錄下kafka
1)先往test.txt中寫入數據class
echo 'test' > test.txt
test
2)開啓connectfile
bin/connect-standalone.sh config/connect-standalone.properties config/connect-file-source.properties config/connect-file-sink.properties
im
3)這時會發現kafka安裝目錄下會有個test.sink.txt文件。cat後會看到test.txt的內容已經寫入到test.sink.txt中了數據
遇到的幾個問題目前不知道是什麼緣由,歡迎你們在評論裏說明下top
1)若是直接vim test.txt會發現無法將內容傳入到topic中文件
2)vim test.txt後,再echo 內容到test.txt也會致使內容沒法寫入到topic中。須要從新啓動connect才行