I created the below interceptor to save all commands
@Bean
fun configureCommandBus(domainCommandRepository: DomainCommandRepository): CommandBus {
val commandBus: CommandBus = SimpleCommandBus.builder().build()
commandBus.registerHandlerInterceptor(CommandHandlerInterceptor(domainCommandRepository))
return commandBus
}
class CommandHandlerInterceptor(private val domainCommandRepository: DomainCommandRepository) :
MessageHandlerInterceptor<CommandMessage<*>> {
@Throws(Exception::class)
override fun handle(unitOfWork: UnitOfWork<out CommandMessage<*>>, interceptorChain: InterceptorChain): Any {
val cmd = unitOfWork.message
val commandName = cmd.commandName
if (!commandName.startsWith("com.test.domains.user") && !commandName.startsWith("com.test.domains.version") &&
!commandName.startsWith("com.test.domains.mcc")) {
val identifier = cmd.identifier
val payload = cmd.payload
val currentDateTime = LocalDateTime.now()
val formatter = DateTimeFormatter.ISO_DATE_TIME
domainCommandRepository.save(
DomainCommand(
UUID.randomUUID().toString(),
identifier,
commandName,
payload,
currentDateTime.format(formatter)
)
)
}
return interceptorChain.proceed()
}
}
the Interceptor works fine, but with same commands i have this error interceptorChain.proceed() must not be null
, any explication please