Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/tech/buildrun/sqs/SqsApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public static void main(String[] args) {
@Override
public void run(String... args) throws Exception {
var SQS = "https://localhost.localstack.cloud:4566/000000000000/minha-fila";
sqsTemplate.send(SQS, new MyMessage("meu valor de start"));
sqsTemplate.send(SQS, new MyMessage("My automatic start message"));
}
}
2 changes: 2 additions & 0 deletions src/main/java/tech/buildrun/sqs/config/SqsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;

Expand All @@ -14,6 +15,7 @@ public class SqsConfig {
public SqsAsyncClient sqsAsyncClient() {
return SqsAsyncClient.builder()
.endpointOverride(URI.create("http://localhost:4566"))
.credentialsProvider(AnonymousCredentialsProvider.create())
.region(Region.SA_EAST_1)
.build();
}
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/tech/buildrun/sqs/controller/SqsProducer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package tech.buildrun.sqs.controller;

import io.awspring.cloud.sqs.operations.SqsTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.buildrun.sqs.consumer.MyMessage;

@RestController
@RequestMapping("sqs/v1/messages")
public class SqsProducer {

@Autowired
private SqsTemplate sqsTemplate;


@PostMapping("/send")
public void sendMessage(@RequestBody MyMessage message){
var SQS = "https://localhost.localstack.cloud:4566/000000000000/minha-fila";
sqsTemplate.send(SQS, message);
}
}