Skip to content

Commit

Permalink
Merge pull request #45307 from gsmet/dev-services-pg-xa
Browse files Browse the repository at this point in the history
Make PostgreSQL Dev Services compatible with XA by default
  • Loading branch information
gsmet authored Dec 28, 2024
2 parents 0d3fee5 + 0fa9369 commit 6ce7dcf
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class PostgresqlDevServicesProcessor {

private static final Logger LOG = Logger.getLogger(PostgresqlDevServicesProcessor.class);

private static final String MAX_PREPARED_TRANSACTIONS = "max_prepared_transactions";
private static final String DEFAULT_MAX_PREPARED_TRANSACTIONS = "--" + MAX_PREPARED_TRANSACTIONS + "=100";

@BuildStep
ConsoleCommandBuildItem psqlCommand(DevServicesLauncherConfigResultBuildItem devServices) {
return new ConsoleCommandBuildItem(new PostgresCommand(devServices));
Expand Down Expand Up @@ -75,7 +78,16 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt
container.withEnv(containerConfig.getContainerEnv());

containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam);
containerConfig.getCommand().ifPresent(container::setCommand);
String augmentedCommand;
if (containerConfig.getCommand().isPresent()) {
String originalCommand = containerConfig.getCommand().get();
augmentedCommand = originalCommand.contains(MAX_PREPARED_TRANSACTIONS) ? originalCommand
: originalCommand + " " + DEFAULT_MAX_PREPARED_TRANSACTIONS;
} else {
augmentedCommand = DEFAULT_MAX_PREPARED_TRANSACTIONS;
}
container.setCommand(augmentedCommand);

containerConfig.getInitScriptPath().ifPresent(container::withInitScript);
if (containerConfig.isShowLogs()) {
container.withLogConsumer(new JBossLoggingConsumer(LOG));
Expand Down

0 comments on commit 6ce7dcf

Please sign in to comment.