So I'm currently developing application using Spring boot with Axonframework, So in Axonframework there is something called aggregate. It can store some states and etc. Everything work fine, but there's a case where I have to check the same state to every incoming command before update the aggregate. Something like this
@CommandHandler
fun handle(command: UpdateProductCommand){
if (isProductApproved){
throw IllegalArgumentException("This product has not been approved by qa.")
}
... do something
}
@CommandHandler
fun handle(command: PublishProductCommand){
if (isProductApproved){
throw IllegalArgumentException("This product has not been approved by qa.")
}
... do something
}
... Some other commands
... Check the same state again and again to every command
As you can see, I have to check this isProductApproved to most of the commands. Is there anyway to easily apply this checking state to every functions or commands before start doing some logic. I would expect something like this
@Aggregate
@CheckState(value = isProductApproved)
class ProductAggregate {
... apply to every command
}
Or any better ways.
question from:
https://stackoverflow.com/questions/66059291/axonframework-how-can-i-apply-the-same-state-check-to-every-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…