Blocking
Marks a function as blocking, indicating it should not be executed asynchronously.
Functions annotated with @Blocking will be executed synchronously, blocking the calling thread until completion. This is useful for operations that:
Require immediate results
Have external dependencies that don't support async execution
Need to maintain thread-local context
Must complete within the current transaction boundary
Use this annotation sparingly, as blocking operations can reduce system throughput and responsiveness. Prefer asynchronous processing when possible.
Example usage:
@AggregateRoot
class OrderAggregate {
@OnCommand
@Blocking
fun processPayment(command: ProcessPaymentCommand): PaymentProcessed {
// Synchronous payment processing that blocks until complete
val result = paymentGateway.charge(command.amount)
return PaymentProcessed(command.orderId, result.transactionId)
}
}Content copied to clipboard