File tree Expand file tree Collapse file tree 7 files changed +109
-4
lines changed
java/br/com/grupo63/serviceproduction
test/java/br/com/grupo63/serviceproduction Expand file tree Collapse file tree 7 files changed +109
-4
lines changed Original file line number Diff line number Diff line change 16
16
<description >FIAP SOAT1 2023 - Group 63 - Phase 4</description >
17
17
<properties >
18
18
<java .version>17</java .version>
19
+ <aws .sdk.version>1.12.674</aws .sdk.version>
19
20
</properties >
20
21
<repositories >
21
22
<repository >
22
23
<id >jitpack.io</id >
23
24
<url >https://jitpack.io</url >
24
25
</repository >
25
26
</repositories >
27
+ <dependencyManagement >
28
+ <dependencies >
29
+ <dependency >
30
+ <groupId >io.awspring.cloud</groupId >
31
+ <artifactId >spring-cloud-aws-dependencies</artifactId >
32
+ <version >3.0.0</version >
33
+ <type >pom</type >
34
+ <scope >import</scope >
35
+ </dependency >
36
+ </dependencies >
37
+ </dependencyManagement >
26
38
<dependencies >
27
39
<dependency >
28
40
<groupId >org.springframework.boot</groupId >
36
48
<groupId >org.springframework.boot</groupId >
37
49
<artifactId >spring-boot-starter-validation</artifactId >
38
50
</dependency >
51
+ <dependency >
52
+ <groupId >io.awspring.cloud</groupId >
53
+ <artifactId >spring-cloud-aws-starter</artifactId >
54
+ </dependency >
55
+ <dependency >
56
+ <groupId >io.awspring.cloud</groupId >
57
+ <artifactId >spring-cloud-aws-starter-sqs</artifactId >
58
+ </dependency >
39
59
<dependency >
40
60
<groupId >org.springframework.boot</groupId >
41
61
<artifactId >spring-boot-devtools</artifactId >
85
105
<dependency >
86
106
<groupId >com.amazonaws</groupId >
87
107
<artifactId >aws-java-sdk-dynamodb</artifactId >
88
- <version >1.12.641</version >
108
+ <version >${aws.sdk.version} </version >
109
+ </dependency >
110
+ <dependency >
111
+ <groupId >com.amazonaws</groupId >
112
+ <artifactId >aws-java-sdk-sqs</artifactId >
113
+ <version >${aws.sdk.version} </version >
89
114
</dependency >
90
115
<dependency >
91
116
<groupId >com.github.derjust</groupId >
Original file line number Diff line number Diff line change 6
6
import br .com .grupo63 .techchallenge .common .api .controller .AbstractAPIController ;
7
7
import br .com .grupo63 .techchallenge .common .exception .NotFoundException ;
8
8
import br .com .grupo63 .techchallenge .common .exception .ValidationException ;
9
+ import io .awspring .cloud .sqs .operations .SqsTemplate ;
9
10
import io .swagger .v3 .oas .annotations .Operation ;
10
11
import io .swagger .v3 .oas .annotations .Parameter ;
11
12
import io .swagger .v3 .oas .annotations .tags .Tag ;
22
23
public class StatusAPIController extends AbstractAPIController {
23
24
24
25
private final StatusController controller ;
26
+ private final SqsTemplate sqsTemplate ;
27
+
28
+ @ GetMapping ("/batata" )
29
+ public void batata () {
30
+ sqsTemplate .send (sqsSendOptions ->
31
+ sqsSendOptions
32
+ .queue ("approvedPayments.fifo" )
33
+ .payload (12 ));
34
+ }
25
35
26
36
@ Operation (
27
37
tags = "5ª chamada - Fluxo principal - Acompanhamento e entrega" ,
Original file line number Diff line number Diff line change
1
+ package br .com .grupo63 .serviceproduction .api .controller .status ;
2
+
3
+ import br .com .grupo63 .serviceproduction .controller .StatusController ;
4
+ import com .amazonaws .services .sqs .model .Message ;
5
+ import io .awspring .cloud .sqs .annotation .SqsListener ;
6
+ import lombok .RequiredArgsConstructor ;
7
+ import org .springframework .stereotype .Component ;
8
+
9
+ import java .util .Arrays ;
10
+
11
+ @ RequiredArgsConstructor
12
+
13
+ @ Component
14
+ public class StatusQueueController {
15
+ private final StatusController controller ;
16
+
17
+ @ SqsListener (value = "approvedPayments.fifo" )
18
+ public void processMessage (int message ) {
19
+ System .err .println (message );
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -28,9 +28,9 @@ public class DynamoDBConfig {
28
28
private String amazonAWSSecretKey ;
29
29
30
30
@ Bean
31
- public AmazonDynamoDB amazonDynamoDB () {
31
+ public AmazonDynamoDB amazonDynamoDB (AWSCredentials awsCredentials ) {
32
32
AmazonDynamoDB amazonDynamoDB
33
- = new AmazonDynamoDBClient (amazonAWSCredentials () );
33
+ = new AmazonDynamoDBClient (awsCredentials );
34
34
35
35
if (!StringUtils .isEmpty (amazonDynamoDBEndpoint )) {
36
36
amazonDynamoDB .setEndpoint (amazonDynamoDBEndpoint );
Original file line number Diff line number Diff line change
1
+ package br .com .grupo63 .serviceproduction .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 .AwsBasicCredentials ;
8
+ import software .amazon .awssdk .auth .credentials .StaticCredentialsProvider ;
9
+ import software .amazon .awssdk .regions .Region ;
10
+ import software .amazon .awssdk .services .sqs .SqsAsyncClient ;
11
+
12
+ @ Configuration
13
+ class SQSClientConfig {
14
+
15
+ @ Value ("${spring.cloud.aws.credentials.access-key}" )
16
+ private String accessKey ;
17
+
18
+ @ Value ("${spring.cloud.aws.credentials.secret-key}" )
19
+ private String secretKey ;
20
+
21
+ @ Value ("${spring.cloud.aws.region.static}" )
22
+ private String region ;
23
+
24
+ @ Bean
25
+ SqsAsyncClient sqsAsyncClient (){
26
+ return SqsAsyncClient
27
+ .builder ()
28
+ .region (Region .of (region ))
29
+ .credentialsProvider (StaticCredentialsProvider
30
+ .create (AwsBasicCredentials .create (accessKey , secretKey )))
31
+ .build ();
32
+ }
33
+
34
+ @ Bean
35
+ public SqsTemplate sqsTemplate (SqsAsyncClient sqsAsyncClient ){
36
+ return SqsTemplate .builder ().sqsAsyncClient (sqsAsyncClient ).build ();
37
+ }
38
+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,15 @@ spring:
13
13
flyway :
14
14
locations : classpath:db/migrations/{vendor}/
15
15
enabled : true
16
+ cloud :
17
+ aws :
18
+ credentials :
19
+ access-key : " ${AMAZON_AWS_ACCESSKEY:accesskey}"
20
+ secret-key : " ${AMAZON_AWS_SECRETKEY:secretkey}"
21
+ region :
22
+ static : " us-east-2"
23
+ sqs :
24
+ endpoint : " ${AMAZON_AWS_SQS_ENDPOINT:endpoint}"
16
25
jwt :
17
26
token :
18
27
key :
@@ -23,6 +32,8 @@ amazon:
23
32
aws :
24
33
accesskey : " ${AMAZON_AWS_ACCESSKEY:accesskey}"
25
34
secretkey : " ${AMAZON_AWS_SECRETKEY:secretkey}"
35
+
26
36
server :
37
+ port : 8082
27
38
servlet :
28
39
context-path : " /production"
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ public void setUp() {
45
45
MockitoAnnotations .openMocks (this );
46
46
statusUseCase = new StatusUseCase (statusJpaAdapter );
47
47
statusController = new StatusController (statusUseCase );
48
- statusAPIController = new StatusAPIController (statusController );
48
+ statusAPIController = new StatusAPIController (statusController , null );
49
49
}
50
50
51
51
@ SneakyThrows
You can’t perform that action at this time.
0 commit comments