Replay does not work and TokenEntry Table is not generated by Axon

Hello there :slight_smile:

We would like to implement our own event processors and replay events on them.

Therefore we have implemented the replay by the following code:

@Component
class Replay(
    private val eventProcessingConfiguration: EventProcessingConfiguration
) {
    fun replay(name: String = "none") : String {
        if (name == "none") return "An replay processing Group must be defined."
        this.eventProcessingConfiguration.eventProcessor(name, TrackingEventProcessor::class.java).ifPresent {
            it.shutDown()
            it.resetTokens()
            it.start()
        }
        return "Replay done."
    }
}

@RestController
class ReplayController(private val replay: Replay) {
    @PostMapping("/replay/{group}")
    fun doReplay(@PathVariable group: String) : ResponseEntity<*> {
        return ResponseEntity.ok(this.replay.replay(group))
    }
}

Event Processors are added by annotation on event handlinc components.

@ProcessingGroup("qualification")
open class Qualification protected constructor() {

    @AggregateIdentifier
    private lateinit var uuid: UUID

    companion object {
        fun create(uuid: UUID, title: String) : Qualification {
            val qualification = Qualification()
            AggregateLifecycle.apply(QualificationCreated(uuid, title))
            return qualification
        }
    }

    @EventSourcingHandler
    fun on(event: QualificationCreated) {
        this.uuid = event.uuid
    }
}
@Component
@ProcessingGroup("qualification")
interface QualificationProjection : Repository<QualificationDetails, String> {
    @EventHandler
    @Modifying
    @Transactional
    @Query("INSERT INTO Qualification (uuid, title) VALUES (:#{#qualificationCreated.uuid}, :#{#qualificationCreated.title})")
    fun write(qualificationCreated: QualificationCreated)
}

Our Problem is, that the replay does not have any effect. I have noticed, that the tables “tokenStore” and other (exept from domainevententry and snapshotevententry) are not generated by default. I had implemented them by myself, but this had no effect as well.

Have I missed any configuration/spring beans?

Hi Christopher,

Your QualificationProjection class looks like a Spring Data repository. I am not sure if combining Repository and EventHandler this way will work. Try creating a separate class that is annotated with @Component and @ProcessingGroup that has an @EventHandler annotated method that interacts with the Repository.

If you don’t use JPA, tables won’t be created automatically. You need to create the TokenStore table yourself. You can trigger the creation by calling the JdbcTokenStore.createSchema(TokenTableFactory) method.

Hope this helps.