After triggering N events, restart the client. Previously triggered events will be triggered in sequence

axonframework version:4.3.3
axon server version: 4.3.5

publish event:

@PostMapping(value = “createPost”)
public void createPost(@RequestBody CreatePostDto createPostDto) {
eventGateway.publish(new PostCreateEvent(UUID.randomUUID().toString(), createPostDto.getTitle(),
createPostDto.getContent()));
}

event handler:

@EventHandler
void handle(EventMessage event) {
System.out.println(“in event handler”);
}

question:

After triggering N events, restart the client. Previously triggered events will be triggered in sequence

logs:

2020-07-21 20:01:43.825 INFO 11676 — [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at ‘/h2-console’. Database available at ‘jdbc:h2:mem:testdb’
2020-07-21 20:01:43.935 INFO 11676 — [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService ‘applicationTaskExecutor’
2020-07-21 20:01:43.980 INFO 11676 — [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-07-21 20:01:44.023 INFO 11676 — [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.17.Final
2020-07-21 20:01:44.137 INFO 11676 — [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-07-21 20:01:44.153 INFO 11676 — [ main] o.a.serialization.ChainingConverter : ContentTypeConverter of type [class org.axonframework.serialization.xml.XomToStringConverter] is ignored. It seems to rely on a class that is not available in the class loader: nu/xom/Document
2020-07-21 20:01:44.163 INFO 11676 — [ main] o.a.serialization.ChainingConverter : ContentTypeConverter of type [class org.axonframework.serialization.xml.InputStreamToXomConverter] is ignored. It seems to rely on a class that is not available in the class loader: nu/xom/ParsingException
2020-07-21 20:01:44.232 INFO 11676 — [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-07-21 20:01:44.258 WARN 11676 — [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-07-21 20:01:44.521 INFO 11676 — [ main] o.a.a.c.AxonServerConnectionManager : Connecting using unencrypted connection…
2020-07-21 20:01:44.871 INFO 11676 — [ main] o.a.a.c.AxonServerConnectionManager : Requesting connection details from localhost:8124
2020-07-21 20:01:44.885 INFO 11676 — [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-07-21 20:01:44.900 INFO 11676 — [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit ‘default’
2020-07-21 20:01:45.205 INFO 11676 — [ main] o.a.a.c.AxonServerConnectionManager : Reusing existing channel
2020-07-21 20:01:45.211 INFO 11676 — [ main] o.a.a.c.AxonServerConnectionManager : Re-subscribing commands and queries
2020-07-21 20:01:45.228 INFO 11676 — [ main] o.a.a.c.query.AxonServerQueryBus : Creating new query stream subscriber
2020-07-21 20:01:45.272 INFO 11676 — [ main] o.a.a.c.command.AxonServerCommandBus : Creating new command stream subscriber
2020-07-21 20:01:45.297 INFO 11676 — [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ‘’
2020-07-21 20:01:45.298 INFO 11676 — [ main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-07-21 20:01:45.400 INFO 11676 — [ main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-07-21 20:01:45.408 INFO 11676 — [ main] c.s.s.SpringBootAxonApplication : Started SpringBootAxonApplication in 3.394 seconds (JVM running for 3.674)
2020-07-21 20:01:45.487 INFO 11676 — [axon.service]-0] o.a.e.TrackingEventProcessor : Worker assigned to segment Segment[0/0] for processing
2020-07-21 20:01:45.489 INFO 11676 — [axon.service]-0] o.a.e.TrackingEventProcessor : Using current Thread for last segment worker: TrackingSegmentWorker{processor=cn.sailing.springbootaxon.service, segment=Segment[0/0]}
2020-07-21 20:01:45.492 INFO 11676 — [axon.service]-0] o.a.e.TrackingEventProcessor : Fetched token: null for segment: Segment[0/0]
2020-07-21 20:01:45.496 INFO 11676 — [axon.service]-0] o.a.a.c.event.axon.AxonServerEventStore : open stream: 0
in event handler
in event handler
in event handler
in event handler
in event handler

sorry but I can’t understand what is your question. Can you please write it down better?

In any case, remember that from your log I see that your client application start with an in memory db. This means that every time you restart the client data are lost and all your events store in the event store will be handled again.

To clarify this you can configure your application to save your db in a file
spring.datasource.url=jdbc:h2:./runtime/client/testdb;AUTO_SERVER=TRUE
Axon Framework will take care to store information about the last processed token : this will prevent your application to handle all the events in the event store again.

You can find further information on the reference guide https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#token-store

Best.

Thank you

在 2020年7月21日星期二 UTC+8下午10:15:15,Corrado Musumeci写道: