New file |
| | |
| | | package com.kidgrow.rabbitmq.send; |
| | | |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: <br> |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/3/23 18:45 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @Component |
| | | public class TopicSender { |
| | | // @Autowired |
| | | // private AmqpTemplate rabbitTemplate; |
| | | |
| | | @Autowired |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | |
| | | public void send() { |
| | | for(int i=1;i<10000;i++) { |
| | | String context = "hi, i am message:"+i; |
| | | this.rabbitTemplate.setQueue("AIEvaluation"); |
| | | this.rabbitTemplate.convertAndSend("test_exchange", "test_routingKey", context); |
| | | } |
| | | } |
| | | } |