File tree Expand file tree Collapse file tree 6 files changed +46
-4
lines changed 
test/java/com/xncoding/service Expand file tree Collapse file tree 6 files changed +46
-4
lines changed Original file line number Diff line number Diff line change 22
33消息队列RabbitMQ的使用例子,演示Direct模式和广播发送模式。
44
5- 测试用例:` com.xncoding.service.SenderServiceTest.java ` 
5+ ## 测试步骤  
6+ 
7+ 1 .  先安装rabbitmq并初始化spring用户
8+ 2 .  配置application.yml里面的连接信息
9+ 3 .  启动程序
10+ 
11+ 有两种测试方式,一种是通过编写AfterStartRunner来直接看启动效果。
12+ 另外一种是运行测试用例:` com.xncoding.service.SenderServiceTest.java ` 
613
714## 许可证  
815
Original file line number Diff line number Diff line change 2929			<groupId >org.springframework.boot</groupId >
3030			<artifactId >spring-boot-starter-amqp</artifactId >
3131		</dependency >
32+         <dependency >
33+             <groupId >com.fasterxml.jackson.core</groupId >
34+             <artifactId >jackson-databind</artifactId >
35+             <version >2.9.6</version >
36+         </dependency >
3237
3338        <dependency >
3439            <groupId >org.springframework.boot</groupId >
Original file line number Diff line number Diff line change 1- package  com .xncoding . pos ;
1+ package  com .xncoding ;
22
33import  org .springframework .boot .SpringApplication ;
44import  org .springframework .boot .autoconfigure .SpringBootApplication ;
Original file line number Diff line number Diff line change 1+ package  com .xncoding .pos ;
2+ 
3+ import  com .xncoding .pos .service .SenderService ;
4+ import  org .springframework .beans .factory .annotation .Autowired ;
5+ import  org .springframework .boot .CommandLineRunner ;
6+ import  org .springframework .core .annotation .Order ;
7+ import  org .springframework .stereotype .Component ;
8+ 
9+ /** 
10+  * AfterStartRunner 
11+  * 
12+  * @author XiongNeng 
13+  * @version 1.0 
14+  * @since 2018/9/15 
15+  */ 
16+ @ Component 
17+ @ Order (1 )
18+ public  class  AfterStartRunner  implements  CommandLineRunner  {
19+     @ Autowired 
20+     private  SenderService  senderService ;
21+     @ Override 
22+     public  void  run (String ... args ) throws  Exception  {
23+         System .out .println ("--------------start-------------" );
24+         Thread .sleep (2000L );
25+         // 测试广播模式 
26+         senderService .broadcast ("AfterStartRunner --> 同学们集合啦!" );
27+         // 测试Direct模式 
28+         senderService .direct ("AfterStartRunner --> 定点消息" );
29+     }
30+ }
Original file line number Diff line number Diff line change @@ -34,5 +34,5 @@ logging:
3434    ROOT : INFO 
3535    com :
3636      xncoding : DEBUG 
37-   file : E :/logs/app.log
37+   file : D :/logs/app.log
3838
Original file line number Diff line number Diff line change 11package  com .xncoding .service ;
22
3- import  com .xncoding .pos . Application ;
3+ import  com .xncoding .Application ;
44import  com .xncoding .pos .service .SenderService ;
55import  org .junit .Test ;
66import  org .junit .runner .RunWith ;
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments