ityestop opened a new issue, #424:
URL: https://github.com/apache/rocketmq-connect/issues/424

   **问题描述**
   在进行rocketmq-connect-runtime测试时,使用文档中的测试用例,结果运行结果是对的,可以正常生成文件,但是传递的topic是 
null。
   <img width="1570" alt="image" 
src="https://user-images.githubusercontent.com/14820088/218269291-3b34b8e8-ec43-46d7-987a-1f8afb7d6614.png";>
   
   
   
   **配置问题**
   使用当前master分支(92c14dac8f5667b64aa532bdab411cb95bc18f2c)打包配置,无变化
   
   **使用rocketMq 版本**
   rocketMq版本 4.9.2
   rocketMq-client 4.7.1
   
   **触发命令**
   ```
   curl -X POST -H "Content-Type: application/json" 
http://127.0.0.1:8082/connectors/fileSourceConnector -d 
'{"connector.class":"org.apache.rocketmq.connect.file.FileSourceConnector","filename":"test-source-file.txt","connect.topicname":"fileTopic"}'
   ```
   
   **排查问题**
   
https://github.com/apache/rocketmq-connect/blob/92c14dac8f5667b64aa532bdab411cb95bc18f2c/rocketmq-connect-sample/src/main/java/org/apache/rocketmq/connect/file/FileSourceTask.java#L149
   
   <img width="1188" alt="image" 
src="https://user-images.githubusercontent.com/14820088/218269388-f3c080a4-7249-41c9-a14d-59c9ef6d92ee.png";>
   当前代码获取 `fileConfig.topic`,但是在 connector 创建时传入的是 connect.topicname, 
不存在赋值。此时一定为null传入,但是根据代码排查,调用的方法为 
io.openmessaging.connector.api.data.ConnectRecord#addExtension(java.lang.String,
 java.lang.String)
   最终执行方法为 
/Users/cchu/.m2/repository/io/openmessaging/openmessaging-api/0.3.1-alpha/openmessaging-api-0.3.1-alpha.jar!/io/openmessaging/internal/DefaultKeyValue.class:35
   <img width="654" alt="image" 
src="https://user-images.githubusercontent.com/14820088/218269683-67b3d720-08d0-49cd-b77a-08859538c157.png";>
   根据java.lang.String#valueOf(java.lang.Object) 查看,发现对象传入为null时,返回的是”null“字符串。
   
   
https://github.com/apache/rocketmq-connect/blob/92c14dac8f5667b64aa532bdab411cb95bc18f2c/rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/connectorwrapper/WorkerSourceTask.java#L422
   
   <img width="698" alt="image" 
src="https://user-images.githubusercontent.com/14820088/218270112-438e2bd8-8b85-4f2a-bc2e-66cccd841825.png";>
   
   
在org.apache.rocketmq.connect.runtime.connectorwrapper.WorkerSourceTask#maybeCreateAndGetTopic方法中的判断,优先取topic,补偿取
 connect.topicname 。由于 topic = "null",最终导致创建topic为 null
   
   
   以上是排查的定位,不排除个人用法不当导致的问题,希望有朋友可以一直帮忙double check一下。
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to