-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from FloRul/feature/formulaire
Response with form.
- Loading branch information
Showing
5 changed files
with
118 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...sorFunction/src/main/java/com/levio/awsdemo/formrequestprocessor/service/MailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.levio.awsdemo.formrequestprocessor.service; | ||
|
||
import jakarta.mail.MessagingException; | ||
import jakarta.mail.Session; | ||
import jakarta.mail.internet.MimeMessage; | ||
|
||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
public class MailService { | ||
|
||
public MimeMessage getMimeMessage(InputStream inputStream) throws MessagingException { | ||
Properties props = new Properties(); | ||
Session session = Session.getDefaultInstance(props, null); | ||
|
||
return new MimeMessage(session, inputStream); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...tion/src/main/java/com/levio/awsdemo/formrequestprocessor/service/SqsProducerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.levio.awsdemo.formrequestprocessor.service; | ||
|
||
import com.amazonaws.services.lambda.runtime.events.SQSEvent; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.sqs.SqsClient; | ||
import software.amazon.awssdk.services.sqs.model.MessageAttributeValue; | ||
import software.amazon.awssdk.services.sqs.model.SendMessageRequest; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class SqsProducerService { | ||
private static final String QUEUE_URL = System.getenv("QUEUE_URL"); | ||
private final SqsClient sqs = SqsClient.builder() | ||
.region(Region.US_EAST_1) | ||
.build(); | ||
|
||
public void send(String message, Map<String, SQSEvent.MessageAttribute> messageAttributes, String messageId) { | ||
Map<String, MessageAttributeValue> messageAttributeValues = new HashMap<>(); | ||
messageAttributes.forEach((key, value) -> { | ||
MessageAttributeValue mav = MessageAttributeValue.builder() | ||
.stringValue(value.getStringValue()) | ||
.dataType(value.getDataType()) | ||
.build(); | ||
messageAttributeValues.put(key, mav); | ||
}); | ||
|
||
SendMessageRequest sendMessageRequest = SendMessageRequest.builder() | ||
.queueUrl(QUEUE_URL) | ||
.messageBody(message) | ||
.messageAttributes(messageAttributeValues) | ||
.messageGroupId(messageAttributes.get("sender").getStringValue()) | ||
.messageDeduplicationId(messageId) | ||
.build(); | ||
|
||
sqs.sendMessage(sendMessageRequest); | ||
} | ||
} |