File tree Expand file tree Collapse file tree 4 files changed +86
-0
lines changed
src/main/java/io/sobok/SobokSobok Expand file tree Collapse file tree 4 files changed +86
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ dependencies {
57
57
58
58
// Health Check
59
59
implementation ' org.springframework.boot:spring-boot-starter-actuator'
60
+
61
+ // AWS
62
+ implementation platform(" io.awspring.cloud:spring-cloud-aws-dependencies:3.0.1" )
63
+ implementation ' io.awspring.cloud:spring-cloud-aws-starter-sqs'
60
64
}
61
65
62
66
tasks. named(' bootBuildImage' ) {
Original file line number Diff line number Diff line change
1
+ package io .sobok .SobokSobok .config ;
2
+
3
+ import io .awspring .cloud .sqs .operations .SqsTemplate ;
4
+ import org .springframework .beans .factory .annotation .Value ;
5
+ import org .springframework .context .annotation .Bean ;
6
+ import org .springframework .context .annotation .Configuration ;
7
+ import software .amazon .awssdk .auth .credentials .AwsCredentials ;
8
+ import software .amazon .awssdk .regions .Region ;
9
+ import software .amazon .awssdk .services .sqs .SqsAsyncClient ;
10
+
11
+ @ Configuration
12
+ public class SQSConfig {
13
+
14
+ @ Value ("${spring.cloud.aws.credentials.access-key}" )
15
+ private String AWS_ACCESS_KEY ;
16
+
17
+ @ Value ("${spring.cloud.aws.credentials.secret-key}" )
18
+ private String AWS_SECRET_KEY ;
19
+
20
+ @ Value ("${spring.cloud.aws.region.static}" )
21
+ private String AWS_REGION ;
22
+
23
+ @ Bean
24
+ public SqsAsyncClient sqsAsyncClient () {
25
+ return SqsAsyncClient .builder ()
26
+ .credentialsProvider (() -> new AwsCredentials () {
27
+ @ Override
28
+ public String accessKeyId () {
29
+ return AWS_ACCESS_KEY ;
30
+ }
31
+
32
+ @ Override
33
+ public String secretAccessKey () {
34
+ return AWS_SECRET_KEY ;
35
+ }
36
+ })
37
+ .region (Region .of (AWS_REGION ))
38
+ .build ();
39
+ }
40
+
41
+ @ Bean
42
+ public SqsTemplate sqsTemplate () {
43
+ return SqsTemplate .newTemplate (sqsAsyncClient ());
44
+ }
45
+ }
Original file line number Diff line number Diff line change
1
+ package io .sobok .SobokSobok .external .aws .sqs ;
2
+
3
+ import io .awspring .cloud .sqs .operations .SendResult ;
4
+ import io .awspring .cloud .sqs .operations .SqsTemplate ;
5
+ import org .springframework .beans .factory .annotation .Value ;
6
+ import org .springframework .stereotype .Component ;
7
+ import software .amazon .awssdk .services .sqs .SqsAsyncClient ;
8
+
9
+ @ Component
10
+ public class SQSMessageSender {
11
+
12
+ private final SqsTemplate queueMessagingTemplate ;
13
+
14
+ @ Value ("${spring.cloud.aws.sqs.name}" )
15
+ private String QUEUE_NAME ;
16
+
17
+ public SQSMessageSender (SqsAsyncClient sqsAsyncClient ) {
18
+ this .queueMessagingTemplate = SqsTemplate .newTemplate (sqsAsyncClient );
19
+ }
20
+
21
+ public SendResult <SQSPushNotificationRequest > sendMessage (SQSPushNotificationRequest request ) {
22
+ return queueMessagingTemplate .send (to -> to
23
+ .queue (QUEUE_NAME )
24
+ .payload (request ));
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ package io .sobok .SobokSobok .external .aws .sqs ;
2
+
3
+ public record SQSPushNotificationRequest (
4
+
5
+ String deviceToken ,
6
+
7
+ String title ,
8
+
9
+ String content
10
+ ) {
11
+ }
You can’t perform that action at this time.
0 commit comments