File tree Expand file tree Collapse file tree 7 files changed +95
-0
lines changed
src/main/java/com/hrk/amqp Expand file tree Collapse file tree 7 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+ <parent >
7
+ <groupId >com.hrk</groupId >
8
+ <artifactId >microservices-tutorial</artifactId >
9
+ <version >1.0-SNAPSHOT</version >
10
+ </parent >
11
+
12
+ <artifactId >amqp</artifactId >
13
+
14
+ <properties >
15
+ <maven .compiler.source>20</maven .compiler.source>
16
+ <maven .compiler.target>20</maven .compiler.target>
17
+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
18
+ </properties >
19
+
20
+ <dependencies >
21
+ <dependency >
22
+ <groupId >org.springframework.boot</groupId >
23
+ <artifactId >spring-boot-starter-amqp</artifactId >
24
+ </dependency >
25
+ </dependencies >
26
+ </project >
Original file line number Diff line number Diff line change
1
+ package com .hrk .amqp ;
2
+
3
+ import lombok .AllArgsConstructor ;
4
+ import org .springframework .amqp .core .AmqpTemplate ;
5
+ import org .springframework .amqp .rabbit .config .SimpleRabbitListenerContainerFactory ;
6
+ import org .springframework .amqp .rabbit .connection .ConnectionFactory ;
7
+ import org .springframework .amqp .rabbit .core .RabbitTemplate ;
8
+ import org .springframework .amqp .support .converter .Jackson2JsonMessageConverter ;
9
+ import org .springframework .amqp .support .converter .MessageConverter ;
10
+ import org .springframework .context .annotation .Bean ;
11
+ import org .springframework .context .annotation .Configuration ;
12
+
13
+ @ Configuration
14
+ @ AllArgsConstructor
15
+ public class RabbitMQConfig {
16
+
17
+ private final ConnectionFactory connectionFactory ;
18
+
19
+ @ Bean
20
+ public AmqpTemplate amqpTemplate () {
21
+ RabbitTemplate rabbitTemplate = new RabbitTemplate (connectionFactory );
22
+ rabbitTemplate .setMessageConverter (jacksonConverter ());
23
+ return rabbitTemplate ;
24
+ }
25
+
26
+ @ Bean
27
+ public SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory (){
28
+ SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory ();
29
+ factory .setConnectionFactory (connectionFactory );
30
+ factory .setMessageConverter (jacksonConverter ());
31
+ return factory ;
32
+ }
33
+
34
+ @ Bean
35
+ public MessageConverter jacksonConverter () {
36
+ return new Jackson2JsonMessageConverter ();
37
+ }
38
+ }
Original file line number Diff line number Diff line change 49
49
<artifactId >spring-cloud-sleuth-zipkin</artifactId >
50
50
</dependency >
51
51
52
+ <dependency >
53
+ <groupId >org.springframework.boot</groupId >
54
+ <artifactId >spring-boot-starter-amqp</artifactId >
55
+ </dependency >
56
+
57
+ <dependency >
58
+ <groupId >com.hrk</groupId >
59
+ <artifactId >amqp</artifactId >
60
+ <version >1.0-SNAPSHOT</version >
61
+ </dependency >
62
+
52
63
<dependency >
53
64
<groupId >com.hrk</groupId >
54
65
<artifactId >clients</artifactId >
Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ services:
32
32
container_name : zipkin
33
33
ports :
34
34
- " 9411:9411"
35
+ rabbitmq :
36
+ image : rabbitmq:3.9.11-management-alpine
37
+ container_name : rabbitmq
38
+ ports :
39
+ - " 5672:5672"
40
+ - " 15672:15672"
35
41
36
42
networks :
37
43
postgres :
Original file line number Diff line number Diff line change 49
49
<artifactId >spring-cloud-sleuth-zipkin</artifactId >
50
50
</dependency >
51
51
52
+ <dependency >
53
+ <groupId >org.springframework.boot</groupId >
54
+ <artifactId >spring-boot-starter-amqp</artifactId >
55
+ </dependency >
56
+
57
+ <dependency >
58
+ <groupId >com.hrk</groupId >
59
+ <artifactId >amqp</artifactId >
60
+ <version >1.0-SNAPSHOT</version >
61
+ </dependency >
62
+
52
63
<dependency >
53
64
<groupId >com.hrk</groupId >
54
65
<artifactId >clients</artifactId >
Original file line number Diff line number Diff line change 17
17
<module >clients</module >
18
18
<module >notification</module >
19
19
<module >apigw</module >
20
+ <module >amqp</module >
20
21
</modules >
21
22
22
23
<properties >
You can’t perform that action at this time.
0 commit comments