Last active
April 26, 2020 10:49
-
-
Save ndemengel/1faadb383b1e8acd5c1bbfca3c8e6aca to your computer and use it in GitHub Desktop.
Commanq queue: a command and its companion specification class
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
@Component | |
class PushTransactionForInvoice( | |
private val transactionPushService: TransactionPushService | |
) : Command(PushTransactionForInvoiceSpec::class) { | |
override fun execute(arguments: Map<String, Any?>): CommandExecutionResult { | |
val invoiceId = InvoiceId(arguments["invoiceId"] as String) | |
val transactionId = TransactionId(arguments["transactionId"] as String) | |
transactionPushService.pushTransactionForInvoice(transactionId, invoiceId) | |
// May return FailureOnOurSide or FailureOnProviderSide as well. | |
// Any exception will be caught and considered a FailureOnOurSide, unless | |
// CircuitBreaking.considerExceptionAsFailureIf tells it's a FailureOnProviderSide | |
return Success | |
} | |
} | |
class PushTransactionForInvoiceSpec( | |
transactionId: TransactionId, | |
invoiceId: InvoiceId | |
) : CommandSpecification(mapOf( | |
"invoiceId" to invoiceId.get(), | |
"transactionId" to transactionId.get() | |
)) { | |
companion object { | |
val COMMAND_NAME = "pushTransactionForInvoice" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment