|
@@ -0,0 +1,33 @@
|
|
|
+package org.jeecg.modules.mq;
|
|
|
+
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
+
|
|
|
+import org.jeecg.modules.adweb.enquiry.dto.EnquiryDTO;
|
|
|
+import org.junit.jupiter.api.Disabled;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wfansh
|
|
|
+ */
|
|
|
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
|
+public class RabbitMQTest {
|
|
|
+
|
|
|
+ @Autowired private RabbitTemplate rabbitTemplate;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ @Disabled
|
|
|
+ public void testSendMessage() {
|
|
|
+ int num = 100000;
|
|
|
+ for (int i = 0; i < num; i++) {
|
|
|
+ EnquiryDTO enquiryDTO = new EnquiryDTO();
|
|
|
+ enquiryDTO.setId(RandomUtil.randomInt());
|
|
|
+ enquiryDTO.setMsg(RandomUtil.randomString(16));
|
|
|
+ rabbitTemplate.convertAndSend("enquiry", enquiryDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("Sent messages to enquiry queue num = " + num);
|
|
|
+ }
|
|
|
+}
|