Inheritance NoHandlerForCommandException

I have the below error when i send the CreateAgent command

org.axonframework.commandhandling.NoHandlerForCommandException: No matching handler available to handle command [com.test.domains.partner.api.CreateAgent]. To find a matching handler, note that the command handler’s name should match the command’s name, and all the parameters on the command handling method should be resolvable. It is thus recommended to validate both the name and the parameters.

@Aggregate
open class PartnerAggregate() {

    @AggregateIdentifier
    lateinit var partnerId: String

}
@Aggregate
class AgentAggregate() : PartnerAggregate() {

    @CommandHandler
    @CreationPolicy(AggregateCreationPolicy.CREATE_IF_MISSING)
    fun handle(command: CreateAgent) {

    }
}

Hello @Aymen_Kanzari!

Based on your title, the CreateAgent command is either an abstract class or interface. This means that the aggregate is able to handle a command with the name com.example.mypackage.CreateAgent.

The message your are sending is a concrete class. I can imagine something like com.example.mypackage.CreateApmAgent. The command will also have that name.

By sending a CommandMessage with the proper name, you can match the correct handler. You can do this in the following manner: new GenericCommandMessage(new GenericCommandMessage(payload), "com.example.mypackage.CreateAgent")).

Let me know if this fixes things for you!

thank you for your reply
I share with you the complete example

com.test.domains.partner.api

data class CreateAgent(
    val partnerId: String,
    val code: String,
    val name: String
)
reactorCommandGateway.send<String>(com.test.domains.partner.api.CreateAgent(
      partnerId = UUID.randomUUID().toString(),
      code = action.code,
      name = action.name
   )
)
@Aggregate
class AgentAggregate() : PartnerAggregate() {

    @CommandHandler
    @CreationPolicy(AggregateCreationPolicy.CREATE_IF_MISSING)
    fun handle(command: com.test.domains.partner.api.CreateAgent) {

    }
}

When i change the agent aggregate like below, the aggregate handles the command correctly, so i guess the problem is in the inheritance

@Aggregate
class AgentAggregate() {

    @AggregateIdentifier
    lateinit var partnerId: String

    @CommandHandler
    @CreationPolicy(AggregateCreationPolicy.CREATE_IF_MISSING)
    fun handle(command: com.test.domains.partner.api.CreateAgent) {

    }
}