|
|
@@ -5,7 +5,6 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jms.core.JmsTemplate;
|
|
|
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
@@ -29,21 +28,13 @@ public class ActiveMQController extends BaseController {
|
|
|
@Autowired
|
|
|
Destination defaultQueueDestination;
|
|
|
|
|
|
- @Autowired
|
|
|
- ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
-
|
|
|
@RequestMapping("/send")
|
|
|
@ResponseBody
|
|
|
public Object send() {
|
|
|
long start = System.currentTimeMillis();
|
|
|
for (int i = 0; i < 100; i ++) {
|
|
|
_log.info("发送消息" + (i + 1));
|
|
|
- final long time = System.currentTimeMillis();
|
|
|
- threadPoolTaskExecutor.execute(new Runnable() {
|
|
|
- public void run() {
|
|
|
- JmsUtil.sendMessage(jmsQueueTemplate, defaultQueueDestination, "消息" + time);
|
|
|
- }
|
|
|
- });
|
|
|
+ JmsUtil.sendMessage(jmsQueueTemplate, defaultQueueDestination, "消息" + (i + 1));
|
|
|
}
|
|
|
_log.info("发送消息消耗时间" + (System.currentTimeMillis() - start));
|
|
|
return "success";
|