You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/06/09 15:56:33 UTC
[GitHub] [rocketmq-spring] zhangjidi2016 commented on a change in pull request #266: [ISSUE #262] Sending messages asynchronously use a custom AsyncSender…
zhangjidi2016 commented on a change in pull request #266:
URL: https://github.com/apache/rocketmq-spring/pull/266#discussion_r437104075
##########
File path: rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/core/RocketMQTemplateTest.java
##########
@@ -87,6 +94,38 @@ public void testSendMessage() {
}
}
+ @Test
+ public void testSendMessage_withCustomAsyncSenderExecutor() {
+ ExecutorService executorService = new ThreadPoolExecutor(
+ 2,
+ 5,
+ 100,
+ TimeUnit.SECONDS,
+ new ArrayBlockingQueue<Runnable>(2000),
+ new ThreadFactory() {
+ private AtomicInteger threadIndex = new AtomicInteger(0);
+
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "AsyncSenderExecutor_" + this.threadIndex.incrementAndGet());
+ }
+ });
+ rocketMQTemplate.setAsyncSenderExecutor(executorService);
+ try {
+ rocketMQTemplate.asyncSend(topic, "payload", new SendCallback() {
+ @Override public void onSuccess(SendResult sendResult) {
+
+ }
+
+ @Override public void onException(Throwable e) {
+
+ }
+ });
+ } catch (MessagingException e) {
+ assertThat(e).hasMessageContaining("org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to [127.0.0.1:9876] failed");
+ }
+ }
+
Review comment:
In this unit test, a custom thread pool in 133 line is used to send messages asynchronously
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org