This is an automated email from the ASF dual-hosted git repository.

gosonzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 291ad70c2b [INLONG-11782][SDK]Adjust the Sender initialization codes 
in example (#11783)
291ad70c2b is described below

commit 291ad70c2b60a7cf49748964e4c9b0572317b1fa
Author: Goson Zhang <4675...@qq.com>
AuthorDate: Wed Feb 26 18:43:37 2025 +0800

    [INLONG-11782][SDK]Adjust the Sender initialization codes in example 
(#11783)
---
 .../inlong/sdk/dataproxy/example/InLongFactoryExample.java  | 13 ++-----------
 .../sdk/dataproxy/example/InLongHttpClientExample.java      |  5 ++---
 .../sdk/dataproxy/example/InLongTcpClientExample.java       | 10 +++++-----
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git 
a/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongFactoryExample.java
 
b/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongFactoryExample.java
index c9e438df3c..8722f7f272 100644
--- 
a/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongFactoryExample.java
+++ 
b/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongFactoryExample.java
@@ -64,10 +64,6 @@ public class InLongFactoryExample {
         InLongTcpMsgSender tcpMsgSender =
                 singleFactory.genTcpSenderByClusterId(tcpMsgSenderConfig);
         ProcessResult procResult = new ProcessResult();
-        if (!tcpMsgSender.start(procResult)) {
-            System.out.println("Start tcp sender failure: process result=" + 
procResult);
-        }
-
         // report data
         ExampleUtils.sendTcpMessages(tcpMsgSender, false, false,
                 groupId, streamId, reqCnt, msgSize, msgCnt, procResult);
@@ -81,9 +77,7 @@ public class InLongFactoryExample {
                 false, managerIp, managerPort, groupId, secretId, secretKey);
         InLongHttpMsgSender httpMsgSender =
                 singleFactory.genHttpSenderByGroupId(httpMsgSenderConfig);
-        if (!httpMsgSender.start(procResult)) {
-            System.out.println("Start http sender failure: process result=" + 
procResult);
-        }
+        // report data
         ExampleUtils.sendHttpMessages(httpMsgSender, false, false,
                 groupId, streamId, reqCnt, msgSize, msgCnt, procResult);
         ExampleUtils.sendHttpMessages(httpMsgSender, false, true,
@@ -99,10 +93,7 @@ public class InLongFactoryExample {
         tcpMsgSenderConfig.setSdkMsgType(MsgType.MSG_ACK_SERVICE);
         InLongTcpMsgSender tcpMsgSender1 =
                 multiFactory1.genTcpSenderByGroupId(tcpMsgSenderConfig);
-        if (!tcpMsgSender1.start(procResult)) {
-            System.out.println("Start tcp sender1 failure: process result=" + 
procResult);
-        }
-
+        // report data
         String managerAddr = "http://"; + managerIp + ":" + managerPort;
         TcpMsgSenderConfig tcpMsgSenderConfig2 =
                 new TcpMsgSenderConfig(managerAddr, groupId, secretId, 
secretKey);
diff --git 
a/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongHttpClientExample.java
 
b/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongHttpClientExample.java
index fccdac4a5c..dd4fecdd6d 100644
--- 
a/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongHttpClientExample.java
+++ 
b/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongHttpClientExample.java
@@ -46,19 +46,18 @@ public class InLongHttpClientExample {
         }
 
         String managerAddr = "http://"; + managerIp + ":" + managerPort;
-
         HttpMsgSenderConfig dataProxyConfig =
                 new HttpMsgSenderConfig(managerAddr, groupId, secretId, 
secretKey);
         InLongHttpMsgSender messageSender = new 
InLongHttpMsgSender(dataProxyConfig);
-
         ProcessResult procResult = new ProcessResult();
         if (!messageSender.start(procResult)) {
+            messageSender.close();
             System.out.println("Start http sender failure: process result=" + 
procResult);
+            return;
         }
 
         System.out.println("InLongHttpMsgSender start, nodes="
                 + messageSender.getProxyNodeInfos());
-
         ExampleUtils.sendHttpMessages(messageSender, true, false,
                 groupId, streamId, reqCnt, msgSize, msgCnt, procResult);
         ExampleUtils.sendHttpMessages(messageSender, true, true,
diff --git 
a/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongTcpClientExample.java
 
b/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongTcpClientExample.java
index fce1404e0d..75995b0cf3 100644
--- 
a/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongTcpClientExample.java
+++ 
b/inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/example/InLongTcpClientExample.java
@@ -46,18 +46,18 @@ public class InLongTcpClientExample {
         }
 
         String managerAddr = "http://"; + managerIp + ":" + managerPort;
-
         TcpMsgSenderConfig dataProxyConfig =
                 new TcpMsgSenderConfig(managerAddr, groupId, secretId, 
secretKey);
         dataProxyConfig.setRequestTimeoutMs(20000L);
         InLongTcpMsgSender messageSender = new 
InLongTcpMsgSender(dataProxyConfig);
-
-        logger.info("InLongTcpMsgSender start");
-
         ProcessResult procResult = new ProcessResult();
         if (!messageSender.start(procResult)) {
-            System.out.println("Start sender failure: process result=" + 
procResult.toString());
+            messageSender.close();
+            System.out.println("Start sender failure: process result=" + 
procResult);
+            return;
         }
+
+        logger.info("InLongTcpMsgSender start");
         ExampleUtils.sendTcpMessages(messageSender, true, false,
                 groupId, streamId, reqCnt, msgSize, msgCnt, procResult);
         ExampleUtils.sendTcpMessages(messageSender, true, true,

Reply via email to