-
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 #21 from FIAP-3SOAT-G15/feature/saga
initial saga
- Loading branch information
Showing
36 changed files
with
367 additions
and
244 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
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
5 changes: 0 additions & 5 deletions
5
src/main/kotlin/com/fiap/payments/adapter/gateway/OrderGateway.kt
This file was deleted.
Oops, something went wrong.
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
13 changes: 0 additions & 13 deletions
13
src/main/kotlin/com/fiap/payments/adapter/gateway/impl/OrderGatewayImpl.kt
This file was deleted.
Oops, something went wrong.
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
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/fiap/payments/adapter/messaging/PaymentSender.kt
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,7 @@ | ||
package com.fiap.payments.adapter.messaging | ||
|
||
import com.fiap.payments.domain.entities.Payment | ||
|
||
interface PaymentSender { | ||
fun sendPayment(payment: Payment) | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/fiap/payments/adapter/messaging/config/MessagingConfig.kt
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,20 @@ | ||
package com.fiap.payments.adapter.messaging.config | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fiap.payments.adapter.messaging.PaymentSender | ||
import com.fiap.payments.adapter.messaging.impl.PaymentSenderImpl | ||
import io.awspring.cloud.sns.core.SnsTemplate | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class MessagingConfig { | ||
|
||
@Bean | ||
fun createPaymentSender(snsTemplate: SnsTemplate, | ||
@Value("\${topic.response-payment}") topicName: String, | ||
objectMapper: ObjectMapper): PaymentSender { | ||
return PaymentSenderImpl(snsTemplate, topicName, objectMapper) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/fiap/payments/adapter/messaging/impl/PaymentSenderImpl.kt
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,20 @@ | ||
package com.fiap.payments.adapter.messaging.impl | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fiap.payments.adapter.messaging.PaymentSender | ||
import com.fiap.payments.domain.entities.Payment | ||
import io.awspring.cloud.sns.core.SnsTemplate | ||
import org.springframework.messaging.support.GenericMessage | ||
|
||
class PaymentSenderImpl( | ||
private val snsTemplate: SnsTemplate, | ||
private val topicName: String, | ||
private val mapper: ObjectMapper | ||
) : PaymentSender { | ||
|
||
override fun sendPayment(payment: Payment) { | ||
snsTemplate.send( | ||
topicName, GenericMessage(mapper.writeValueAsString(payment)) | ||
) | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/kotlin/com/fiap/payments/client/OrderApiClient.kt
This file was deleted.
Oops, something went wrong.
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
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
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/fiap/payments/driver/messaging/consumer/RequestPaymentConsumer.kt
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,28 @@ | ||
package com.fiap.payments.driver.messaging.consumer | ||
|
||
import com.fiap.payments.driver.messaging.event.PaymentRequestEvent | ||
import com.fiap.payments.usecases.ProvidePaymentRequestUseCase | ||
import io.awspring.cloud.sqs.annotation.SqsListener | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.context.event.EventListener | ||
import org.springframework.messaging.MessageHeaders | ||
import org.springframework.messaging.handler.annotation.Headers | ||
import org.springframework.scheduling.annotation.EnableAsync | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
@EnableAsync | ||
class RequestPaymentConsumer( | ||
private val providePaymentRequestUseCase: ProvidePaymentRequestUseCase) { | ||
|
||
private val log = LoggerFactory.getLogger(javaClass) | ||
|
||
|
||
@SqsListener("\${sqs.queues.request-payment}") | ||
fun onMessage(message: PaymentRequestEvent, @Headers headers: MessageHeaders) { | ||
log.info(message.toString()) | ||
providePaymentRequestUseCase.providePaymentRequest(message) | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.