Skip to content

Commit

Permalink
config(ebean): add ebean retry configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker committed Jul 24, 2023
1 parent 27392f9 commit e3406de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public class EntityServiceImpl implements EntityService {
OBJECT_MAPPER.getFactory().setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(maxSize).build());
}

private static final int DEFAULT_MAX_TRANSACTION_RETRY = 3;
private static final int DEFAULT_MAX_TRANSACTION_RETRY = 4;

protected final AspectDao _aspectDao;
private final EventProducer _producer;
Expand All @@ -163,13 +163,26 @@ public class EntityServiceImpl implements EntityService {
// TODO(iprentic): Move this to a common utils location once used in other places
private static final String DELIMITER_SEPARATOR = "␟";

private final Integer ebeanMaxTransactionRetry;

public EntityServiceImpl(
@Nonnull final AspectDao aspectDao,
@Nonnull final EventProducer producer,
@Nonnull final EntityRegistry entityRegistry,
final boolean alwaysEmitChangeLog,
final UpdateIndicesService updateIndicesService,
final PreProcessHooks preProcessHooks) {
this(aspectDao, producer, entityRegistry, alwaysEmitChangeLog, updateIndicesService, preProcessHooks, DEFAULT_MAX_TRANSACTION_RETRY);
}

public EntityServiceImpl(
@Nonnull final AspectDao aspectDao,
@Nonnull final EventProducer producer,
@Nonnull final EntityRegistry entityRegistry,
final boolean alwaysEmitChangeLog,
final UpdateIndicesService updateIndicesService,
final PreProcessHooks preProcessHooks,
final Integer retry) {

_aspectDao = aspectDao;
_producer = producer;
Expand All @@ -178,8 +191,11 @@ public EntityServiceImpl(
_alwaysEmitChangeLog = alwaysEmitChangeLog;
_updateIndicesService = updateIndicesService;
_preProcessHooks = preProcessHooks;
ebeanMaxTransactionRetry = retry != null ? retry : DEFAULT_MAX_TRANSACTION_RETRY;
}



/**
* Retrieves the latest aspects corresponding to a batch of {@link Urn}s based on a provided
* set of aspect names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.apache.avro.generic.IndexedRecord;
import org.apache.kafka.clients.producer.Producer;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
Expand All @@ -24,6 +25,9 @@
@Configuration
public class EntityServiceFactory {

@Value("${EBEAN_MAX_TRANSACTION_RETRY:4}")
private Integer _ebeanMaxTransactionRetry;

@Bean(name = "entityService")
@DependsOn({"entityAspectDao", "kafkaEventProducer", "kafkaHealthChecker",
TopicConventionFactory.TOPIC_CONVENTION_BEAN, "entityRegistry"})
Expand All @@ -40,6 +44,6 @@ protected EntityService createInstance(
final KafkaEventProducer eventProducer = new KafkaEventProducer(producer, convention, kafkaHealthChecker);
FeatureFlags featureFlags = configurationProvider.getFeatureFlags();
return new EntityServiceImpl(aspectDao, eventProducer, entityRegistry,
featureFlags.isAlwaysEmitChangeLog(), updateIndicesService, featureFlags.getPreProcessHooks());
featureFlags.isAlwaysEmitChangeLog(), updateIndicesService, featureFlags.getPreProcessHooks(), _ebeanMaxTransactionRetry);
}
}

0 comments on commit e3406de

Please sign in to comment.