Closed shaykh-salman closed 6 years ago
That won't work. We rely on the postgresql-async driver and that one removed the option to set the application_name:
Can be set using connectHandler. This works for me in Quarkus:
import io.quarkus.reactive.pg.client.PgPoolCreator;
import io.vertx.pgclient.PgConnectOptions;
import io.vertx.pgclient.PgPool;
import io.vertx.sqlclient.PoolOptions;
import jakarta.inject.Singleton;
@Singleton
public class CustomPgPoolCreator implements PgPoolCreator {
@Override
public PgPool create(Input input) {
PgConnectOptions connectOptions = input.pgConnectOptionsList().get(0);
PoolOptions poolOptions = input.poolOptions();
return PgPool.pool(input.vertx(), connectOptions, poolOptions)
.connectHandler(sqlConnection -> sqlConnection
.query("set application_name = 'my-app'")
.execute()
.onFailure(Throwable::printStackTrace)
.onComplete(rs -> sqlConnection.close()));
}
}
Can be set using connectHandler. This works for me in Quarkus:
import io.quarkus.reactive.pg.client.PgPoolCreator; import io.vertx.pgclient.PgConnectOptions; import io.vertx.pgclient.PgPool; import io.vertx.sqlclient.PoolOptions; import jakarta.inject.Singleton; @Singleton public class CustomPgPoolCreator implements PgPoolCreator { @Override public PgPool create(Input input) { PgConnectOptions connectOptions = input.pgConnectOptionsList().get(0); PoolOptions poolOptions = input.poolOptions(); return PgPool.pool(input.vertx(), connectOptions, poolOptions) .connectHandler(sqlConnection -> sqlConnection .query("set application_name = 'my-app'") .execute() .onFailure(Throwable::printStackTrace) .onComplete(rs -> sqlConnection.close())); } }
Wrong driver :)
You are using the new reactive driver which replaced the driver this repository was used for. The new driver supports the option, the old one doesn't.
If you check the current repository README you will se that the driver has been marked DEPRECATED several years ago.
Do we have any option to set application name on postgres like passing applicationName through jdbc url?