File tree Expand file tree Collapse file tree 5 files changed +53
-15
lines changed
main/java/org/hsweb/web/message
java/org/hsweb/web/message Expand file tree Collapse file tree 5 files changed +53
-15
lines changed Original file line number Diff line number Diff line change
1
+ package org .hsweb .web .message ;
2
+
3
+ /**
4
+ * @author zhouhao
5
+ */
6
+ public class MessageHolder {
7
+
8
+ }
Original file line number Diff line number Diff line change 5
5
import org .springframework .beans .factory .annotation .Autowired ;
6
6
import org .springframework .boot .test .context .SpringBootTest ;
7
7
import org .springframework .jms .annotation .EnableJms ;
8
+ import org .springframework .jms .config .JmsListenerContainerFactory ;
9
+ import org .springframework .jms .config .SimpleJmsListenerEndpoint ;
8
10
import org .springframework .jms .core .JmsMessagingTemplate ;
11
+ import org .springframework .jms .core .JmsTemplate ;
12
+ import org .springframework .jms .listener .MessageListenerContainer ;
13
+ import org .springframework .messaging .simp .annotation .SendToUser ;
9
14
import org .springframework .test .context .junit4 .SpringRunner ;
10
15
16
+ import javax .jms .*;
17
+ import javax .jms .Message ;
11
18
import java .util .HashMap ;
12
19
13
20
20
27
public class AmqpTests {
21
28
22
29
@ Autowired
23
- private JmsMessagingTemplate jmsMessagingTemplate ;
30
+ private JmsTemplate template ;
24
31
25
32
@ Test
26
- public void testSend () {
27
- jmsMessagingTemplate .convertAndSend ("test" , new HashMap <>());
33
+ public void testSend () throws InterruptedException {
34
+
35
+ for (int i = 0 ; i < 100 ; i ++) {
36
+ template .convertAndSend ("test2" , "aaaa" + i );
37
+ }
38
+ Thread .sleep (10000 );
39
+
28
40
}
29
41
30
42
}
Original file line number Diff line number Diff line change 1
1
package org .hsweb .web .message ;
2
2
3
3
import org .springframework .jms .annotation .JmsListener ;
4
+ import org .springframework .messaging .simp .annotation .SubscribeMapping ;
4
5
import org .springframework .stereotype .Component ;
5
6
6
7
@ Component
7
8
public class Consumer {
8
9
9
- @ JmsListener (destination = "test" )
10
- public void receiveQueue (String text ) {
11
- System .out .println (text );
12
- }
10
+
11
+ @ JmsListener (destination = "test2" )
12
+ public void receiveQueue3 (String text ) {
13
+ System .out .println ("3:" + text );
14
+ }
15
+
16
+ @ JmsListener (destination = "test2" )
17
+ public void receiveQueue4 (String text ) {
18
+ System .out .println ("4:" + text );
19
+ }
13
20
14
21
}
Original file line number Diff line number Diff line change 1
1
package org .hsweb .web .message ;
2
2
3
- import javax .jms .Queue ;
4
-
5
3
import org .apache .activemq .command .ActiveMQQueue ;
6
-
7
- import org .springframework .boot .SpringApplication ;
4
+ import org .apache .activemq .command .ActiveMQTopic ;
8
5
import org .springframework .boot .autoconfigure .SpringBootApplication ;
9
6
import org .springframework .context .annotation .Bean ;
10
7
import org .springframework .jms .annotation .EnableJms ;
8
+ import org .springframework .jms .listener .adapter .MessageListenerAdapter ;
9
+
10
+ import javax .jms .MessageListener ;
11
+ import javax .jms .Queue ;
12
+ import javax .jms .Topic ;
11
13
12
14
@ SpringBootApplication
13
15
@ EnableJms
14
16
public class SampleActiveMQApplication {
15
17
16
- @ Bean
18
+ @ Bean
17
19
public Queue queue () {
18
- return new ActiveMQQueue ("test" );
19
- }
20
+ return new ActiveMQQueue ("test" );
21
+ }
22
+
23
+ @ Bean
24
+ public Topic topic () {
25
+ ActiveMQTopic topic = new ActiveMQTopic ("test2" );
26
+ return topic ;
27
+ }
20
28
21
29
}
Original file line number Diff line number Diff line change 1
1
spring :
2
2
activemq :
3
- in-memory : true
3
+ in-memory : false
4
+ pool :
5
+ enabled : false
6
+ broker-url : failover:tcp://127.0.0.1:61616
You can’t perform that action at this time.
0 commit comments