Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public void configureStorageEngine(
engineConfig -> engineConfig
.batchSize(100)
.gapCleaningThreshold(250)
.gapTimeout(10000)
.gapTimeout(60000)
.lowestGlobalSequence(1)
.maxGapOffset(60000)
.maxGapOffset(10000)
.persistenceExceptionResolver(
config.getComponent(PersistenceExceptionResolver.class)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,12 @@ If you had customized the `JpaEventStorageEngine` in Axon Framework 4 to, for ex
axon.eventstorage.jpa.batch-size=100
# Threshold for gap cleanup (default: 250)
axon.eventstorage.jpa.gap-cleaning-threshold=250
# Gap timeout in milliseconds (default: 10000)
axon.eventstorage.jpa.gap-timeout=10000
# Gap timeout in milliseconds (default: 60000)
axon.eventstorage.jpa.gap-timeout=60000
# Minimum global index value (default: 1)
axon.eventstorage.jpa.lowest-global-sequence=1
# Max gap distance from highest index (default: 60000)
axon.eventstorage.jpa.max-gap-offset=60000
# Max gap distance from highest index (default: 10000)
axon.eventstorage.jpa.max-gap-offset=10000
# Polling interval in ms for new events (default: 1000)
axon.eventstorage.jpa.polling-interval=1000
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class JpaEventStorageEngineConfigurationProperties {
public JpaEventStorageEngineConfigurationProperties(
@DefaultValue("100") int batchSize,
@DefaultValue("250") int gapCleaningThreshold,
@DefaultValue("10000") int gapTimeout,
@DefaultValue("60000") int gapTimeout,
@DefaultValue("1") long lowestGlobalSequence,
@DefaultValue("60000") int maxGapOffset,
@DefaultValue("10000") int maxGapOffset,
@DefaultValue("1000") long pollingInterval
) {
this.batchSize = batchSize;
Expand Down Expand Up @@ -75,7 +75,7 @@ public int gapCleaningThreshold() {
/**
* Retrieves the time until a gap in global index is considered as timed out.
*
* @return The time until a gap in global index is considered as timed out.
* @return The time until a gap in global index is considered as timed out. Defaults to 60000 ms.
*/
public int gapTimeout() {
return gapTimeout;
Expand All @@ -94,6 +94,7 @@ public long lowestGlobalSequence() {
* Retrieves the maximum distance in sequence numbers between a gap and the event with the highest known index.
*
* @return The maximum distance in sequence numbers between a gap and the event with the highest known index.
* Defaults to 10000.
*/
public int maxGapOffset() {
return maxGapOffset;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2010-2026. Axon Framework
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.axonframework.extension.springboot;

import org.axonframework.eventsourcing.eventstore.jpa.AggregateBasedJpaEventStorageEngineConfiguration;
import org.junit.jupiter.api.*;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Tests the {@link JpaEventStorageEngineConfigurationProperties} binding, verifying that an application that sets no
* {@code axon.eventstorage.jpa.*} property is configured exactly as one that uses
* {@link AggregateBasedJpaEventStorageEngineConfiguration#DEFAULT} directly.
*
* @author Stefan Dragisic
*/
class JpaEventStorageEngineConfigurationPropertiesTest {

private static final AggregateBasedJpaEventStorageEngineConfiguration CORE_DEFAULTS =
AggregateBasedJpaEventStorageEngineConfiguration.DEFAULT;

private static JpaEventStorageEngineConfigurationProperties bindWithoutAnyProperty() {
return new Binder(new MapConfigurationPropertySource(Map.of()))
.bindOrCreate("axon.eventstorage.jpa", JpaEventStorageEngineConfigurationProperties.class);
}

@Nested
class DefaultsMatchTheCoreConfiguration {

@Test
void gapTimeoutDefaultsToTheCoreDefault() {
// given no axon.eventstorage.jpa property is set
// when
JpaEventStorageEngineConfigurationProperties properties = bindWithoutAnyProperty();

// then the gap timeout is not shortened relative to the core default, which would risk losing events
assertThat(properties.gapTimeout()).isEqualTo(CORE_DEFAULTS.gapTimeout());
}

@Test
void maxGapOffsetDefaultsToTheCoreDefault() {
// given no axon.eventstorage.jpa property is set
// when
JpaEventStorageEngineConfigurationProperties properties = bindWithoutAnyProperty();

// then
assertThat(properties.maxGapOffset()).isEqualTo(CORE_DEFAULTS.maxGapOffset());
}

@Test
void everySharedSettingDefaultsToTheCoreDefault() {
// given no axon.eventstorage.jpa property is set
// when
JpaEventStorageEngineConfigurationProperties properties = bindWithoutAnyProperty();

// then every setting the two configuration paths share agrees, so neither path silently drifts
assertThat(properties.batchSize()).isEqualTo(CORE_DEFAULTS.batchSize());
assertThat(properties.gapCleaningThreshold()).isEqualTo(CORE_DEFAULTS.gapCleaningThreshold());
assertThat(properties.gapTimeout()).isEqualTo(CORE_DEFAULTS.gapTimeout());
assertThat(properties.lowestGlobalSequence()).isEqualTo(CORE_DEFAULTS.lowestGlobalSequence());
assertThat(properties.maxGapOffset()).isEqualTo(CORE_DEFAULTS.maxGapOffset());
}
}

@Nested
class ExplicitPropertiesOverrideTheDefaults {

@Test
void gapTimeoutAndMaxGapOffsetAreBoundToTheirOwnProperty() {
// given
MapConfigurationPropertySource source = new MapConfigurationPropertySource(Map.of(
"axon.eventstorage.jpa.gap-timeout", "1234",
"axon.eventstorage.jpa.max-gap-offset", "4321"
));

// when
JpaEventStorageEngineConfigurationProperties properties = new Binder(source)
.bindOrCreate("axon.eventstorage.jpa", JpaEventStorageEngineConfigurationProperties.class);

// then
assertThat(properties.gapTimeout()).isEqualTo(1234);
assertThat(properties.maxGapOffset()).isEqualTo(4321);
}
}
}