You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "zhanghui95 (via GitHub)" <gi...@apache.org> on 2023/03/16 03:48:45 UTC

[GitHub] [rocketmq-clients] zhanghui95 opened a new issue, #398: 咨询下新版本sdk问题

zhanghui95 opened a new issue, #398:
URL: https://github.com/apache/rocketmq-clients/issues/398

   我用的官方消息发送demo示例,rocketmq-client-java:5.0.4,循环发送一万条消息好慢四十多秒 异步也需要十四秒左右。然后换回旧版本sdk,rocketmq-spring-boot-starter:2.2.3,相同发送一万条 六秒左右 异步不到500毫秒,我哪里的姿势不对吗?


-- 
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: commits-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] aaron-ai commented on issue #398: 咨询下新版本sdk问题

Posted by "aaron-ai (via GitHub)" <gi...@apache.org>.
aaron-ai commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1471541393

   ```java
   final ClientServiceProvider provider = ClientServiceProvider.loadService();
   
   // Credential provider is optional for client configuration.
   String accessKey = "yourAccessKey";
   String secretKey = "yourSecretKey";
   SessionCredentialsProvider sessionCredentialsProvider =
       new StaticSessionCredentialsProvider(accessKey, secretKey);
   
   String endpoints = "foobar:8080";
   ClientConfiguration clientConfiguration = ClientConfiguration.newBuilder()
       .setEndpoints(endpoints)
       .setCredentialProvider(sessionCredentialsProvider)
       .build();
   String topic = "yourTopic";
   // In most case, you don't need to create too many producers, singleton pattern is recommended.
   final Producer producer = provider.newProducerBuilder()
       .setClientConfiguration(clientConfiguration)
       // Set the topic name(s), which is optional but recommended. It makes producer could prefetch the topic
       // route before message publishing.
       .setTopics(topic)
       // May throw {@link ClientException} if the producer is not initialized.
       .build();
   // Define your message body.
   byte[] body = "This is a normal message for Apache RocketMQ".getBytes(StandardCharsets.UTF_8);
   String tag = "yourMessageTagA";
   final Message message = provider.newMessageBuilder()
       // Set topic for the current message.
       .setTopic(topic)
       // Message secondary classifier of message besides topic.
       .setTag(tag)
       // Key(s) of the message, another way to mark message besides message id.
       .setKeys("yourMessageKey-0e094a5f9d85")
       .setBody(body)
       .build();
   // Set individual thread pool for send callback.
   ExecutorService sendCallbackExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
       Runtime.getRuntime().availableProcessors(), 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
   Stopwatch stopwatch = Stopwatch.createStarted();
   for (int i = 0; i < 10000; i++) {
       final CompletableFuture<SendReceipt> future = producer.sendAsync(message);
       future.whenCompleteAsync((sendReceipt, throwable) -> {
           if (null != throwable) {
               log.error("Failed to send message", throwable);
           }
       }, sendCallbackExecutor);
   }
   Thread.sleep(3000);
   log.info("cost {} ms", stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
   // Block to avoid exist of background threads.
   Thread.sleep(Long.MAX_VALUE);
   // Close the producer when you don't need it anymore.
   producer.close();
   ```
   
   这是一个可供参考的测试代码。


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] zhanghui95 commented on issue #398: 咨询下新版本sdk问题

Posted by "zhanghui95 (via GitHub)" <gi...@apache.org>.
zhanghui95 commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1472983276

   > 这是我这边每隔 3 秒异步发送 15000 条消息的耗时。机器配置与你相近。在刚启动时候会出现耗时较高的情况,随后趋于稳定。
   > 
   > ![image](https://user-images.githubusercontent.com/19537356/225584603-a53bd51c-cc30-4ce8-a49d-f8ab79a2e1c6.png)
   
   多次验证后 最快一次是4s 可能是电脑性能所致。新版本sdk用的proxy,旧版本用的直连broker,新版本怎么连接broker 不会啊


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] github-actions[bot] commented on issue #398: 咨询下新版本sdk问题

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1528903773

   This issue is stale because it has been open for 30 days with no activity. It will be closed in 3 days if no further activity occurs.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] aaron-ai commented on issue #398: 咨询下新版本sdk问题

Posted by "aaron-ai (via GitHub)" <gi...@apache.org>.
aaron-ai commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1471661117

   这是我这边每隔 3 秒异步发送 15000 条消息的耗时。机器配置与你相近。
   
   ![image](https://user-images.githubusercontent.com/19537356/225584603-a53bd51c-cc30-4ce8-a49d-f8ab79a2e1c6.png)
   
   
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] aaron-ai commented on issue #398: 咨询下新版本sdk问题

Posted by "aaron-ai (via GitHub)" <gi...@apache.org>.
aaron-ai commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1471366092

   发送的延时,一般来说取决于网络延时,另外和自身机器的配置也有一定关系。在我们的实测过程中,并没有出现这么大的耗时。你可以提供一下你的机器配置,客户端日志等信息。


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] github-actions[bot] closed issue #398: 咨询下新版本sdk问题

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #398: 咨询下新版本sdk问题
URL: https://github.com/apache/rocketmq-clients/issues/398


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] aaron-ai commented on issue #398: 咨询下新版本sdk问题

Posted by "aaron-ai (via GitHub)" <gi...@apache.org>.
aaron-ai commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1471534022

   可以提供一下日志和火焰图等信息,我们协助看下。


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] zhanghui95 commented on issue #398: 咨询下新版本sdk问题

Posted by "zhanghui95 (via GitHub)" <gi...@apache.org>.
zhanghui95 commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1471441967

   > 发送的延时,一般来说取决于网络延时,另外和自身机器的配置也有一定关系。在我们的实测过程中,并没有出现这么大的耗时。你可以提供一下你的机器配置,客户端日志等信息。
   
    i5-6500 CPU @ 3.20GHz、16G。server都是本地的啊 新版本和旧版本客户端耗时也相差太大了


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] zhanghui95 commented on issue #398: 咨询下新版本sdk问题

Posted by "zhanghui95 (via GitHub)" <gi...@apache.org>.
zhanghui95 commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1471605681

   > ```java
   > final ClientServiceProvider provider = ClientServiceProvider.loadService();
   > 
   > // Credential provider is optional for client configuration.
   > String accessKey = "yourAccessKey";
   > String secretKey = "yourSecretKey";
   > SessionCredentialsProvider sessionCredentialsProvider =
   >     new StaticSessionCredentialsProvider(accessKey, secretKey);
   > 
   > String endpoints = "foobar:8080";
   > ClientConfiguration clientConfiguration = ClientConfiguration.newBuilder()
   >     .setEndpoints(endpoints)
   >     .setCredentialProvider(sessionCredentialsProvider)
   >     .build();
   > String topic = "yourTopic";
   > // In most case, you don't need to create too many producers, singleton pattern is recommended.
   > final Producer producer = provider.newProducerBuilder()
   >     .setClientConfiguration(clientConfiguration)
   >     // Set the topic name(s), which is optional but recommended. It makes producer could prefetch the topic
   >     // route before message publishing.
   >     .setTopics(topic)
   >     // May throw {@link ClientException} if the producer is not initialized.
   >     .build();
   > // Define your message body.
   > byte[] body = "This is a normal message for Apache RocketMQ".getBytes(StandardCharsets.UTF_8);
   > String tag = "yourMessageTagA";
   > final Message message = provider.newMessageBuilder()
   >     // Set topic for the current message.
   >     .setTopic(topic)
   >     // Message secondary classifier of message besides topic.
   >     .setTag(tag)
   >     // Key(s) of the message, another way to mark message besides message id.
   >     .setKeys("yourMessageKey-0e094a5f9d85")
   >     .setBody(body)
   >     .build();
   > // Set individual thread pool for send callback.
   > ExecutorService sendCallbackExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
   >     Runtime.getRuntime().availableProcessors(), 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
   > Stopwatch stopwatch = Stopwatch.createStarted();
   > for (int i = 0; i < 10000; i++) {
   >     final CompletableFuture<SendReceipt> future = producer.sendAsync(message);
   >     future.whenCompleteAsync((sendReceipt, throwable) -> {
   >         if (null != throwable) {
   >             log.error("Failed to send message", throwable);
   >         }
   >     }, sendCallbackExecutor);
   > }
   > log.info("cost {} ms", stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
   > // Block to avoid exist of background threads.
   > Thread.sleep(Long.MAX_VALUE);
   > // Close the producer when you don't need it anymore.
   > producer.close();
   > ```
   > 
   > 这是一个可供参考的测试代码。
   
   七到十来秒不等,与旧版本每次不超过五百毫秒相差不少


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] aaron-ai commented on issue #398: 咨询下新版本sdk问题

Posted by "aaron-ai (via GitHub)" <gi...@apache.org>.
aaron-ai commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1471611838

   > 可以提供一下日志和火焰图等信息,我们协助看下。
   
   还需要提供一下接入方式是否相同,是否都是连接 proxy 还是有直连 broker 的情况存在。


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] francisoliverlee commented on issue #398: 咨询下新版本sdk问题

Posted by "francisoliverlee (via GitHub)" <gi...@apache.org>.
francisoliverlee commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1489581096

   > > 这是我这边每隔 3 秒异步发送 15000 条消息的耗时。机器配置与你相近。在刚启动时候会出现耗时较高的情况,随后趋于稳定。
   > > ![image](https://user-images.githubusercontent.com/19537356/225584603-a53bd51c-cc30-4ce8-a49d-f8ab79a2e1c6.png)
   > 
   > 多次验证后 最快一次是4s 可能是电脑性能所致。新版本sdk用的proxy,旧版本用的直连broker,新版本怎么连接broker 不会啊
   
   和以前一样的, 使用remoting client sdk,配置namesrv就行
   ```xml
   <dependency>
       <groupId>org.apache.rocketmq</groupId>
       <artifactId>rocketmq-client</artifactId>
       <version>5.1.0</version>
   </dependency>
   ```
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-clients] github-actions[bot] commented on issue #398: 咨询下新版本sdk问题

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #398:
URL: https://github.com/apache/rocketmq-clients/issues/398#issuecomment-1533906672

   This issue was closed because it has been inactive for 3 days since being marked as stale.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org