AxonServerEventScheduler corrupting events?

I am a student and still very new to Axon. I have been trying to get the event AxonServerEventScheduler to work for a project of mine but continue to get very strange behavior. I am using Spring + Kotlin, I have events axon starter dependency. Currently connected to a postgresql db and axon server in docker containers.

All my EventHandlers and EventSourcingHandlers worked great when called through the aggregatelifecycle / event bus and then I tried to schedule an event and I received a stack trace and now my EventHandlers are not being called however my EventSourcingHandlers do work within the aggregate. So far I have tried a few things but the only way to get my events to run again is to shut down the Axon Server docker container, delete the events / data folders, recreate them then turn AxonServer back on which seems to me that events are being corrupted. I had an error/ stack trace before and I fixed it by manually creating the token_entry table. Is there another table I need for the Event Scheduler to work? Here is my configuration and code. If you need the repo link let me know. Due to the limits on new users I can only upload 1 picture.

Configuration:

@ Bean
fun eventScheduler(connectionManager: AxonServerConnectionManager):
    AxonServerEventScheduler {
        return AxonServerEventScheduler.builder()
                        .connectionManager(connectionManager)
                        .build()
}

Token:

val token = eventScheduler.schedule(Duration.ofMillis(2000),
                        CreateContractEvent(
                                contractId = UUID.randomUUID().toString()
                    ))

Configuration & Only configuration other than event bus:

fun eventScheduler(connectionManager: AxonServerConnectionManager):                            AxonServerEventScheduler {
                  return AxonServerEventScheduler.builder()
                           .connectionManager(connectionManager)
                           .build()
}

Handler:

@ Component
class TestEventHandler {
        @ EventHandler
        fun handle(createContractEvent: CreateContractEvent) {
                print("\ninside Event Handler")
        }
}

Hi Tim,
The AxonServerEventScheduler uses a serializer to serialize the events before sending them to Axon Server. By default, this is the xstream serializer. If you have configured the Jackson serializer for the event store, you also need to use that serializer for the event scheduler (and pass it to the builder).
The Java code for creating the event scheduler bean:

@Bean
public EventScheduler eventScheduler(@Qualifier("eventSerializer") Serializer eventSerializer,
                                     AxonServerConnectionManager connectionManager) {
    return AxonServerEventScheduler.builder()
                                   .eventSerializer(eventSerializer)
                                   .connectionManager(connectionManager)
                                   .build();
}

Thank you for the response!

I am not quite sure what you mean. I am using the defaults and have not configured a Jackson serializer for the event store. This is my complete config with adding the serializer to the event scheduler bean however I am experiencing the same behavior.

@Configuration
class AxonConfig {
    @Bean
    @Primary
    fun eventScheduler(connectionManager: AxonServerConnectionManager,
                       eventSerializer: Serializer
                       ): EventScheduler {
        return AxonServerEventScheduler.builder()
                .eventSerializer(eventSerializer)
                .connectionManager(connectionManager)
                .build()
    }

    @Bean
    @Primary
    fun eventBus(eventBus: EventBus) : EventBus {
        return eventBus
    }
}

Hi Tim,
You found an issue in Axon Framework scheduling events in Axon Server. What happens is that it does not include the event in the schedule message. We will have a fix for this in the next patch release. For now you can use one of the other EventScheduler implementations (SimpleEventScheduler or QuartzEventScheduler).

1 Like

As it stands, the fix has been created, but reside in the axonserver-connector-java version 4.4.3.
Framework at the moment uses 4.4.2 still.
Nonetheless there is the option to override said version with 4.4.3, allowing you to actually use Axon Server as the means to schedule events.

Confident a framework release (4.4.4 to be exact) will follow soon, if you would prefer to not adjust a transitive dependency.