Skip to content

There is no possibility to establish a connection to the Postgress cluster #2286

Open
@Dem1616

Description

@Dem1616

Hibernate reactive 3.0, vertx 4.5.14.
When specifying multiple hosts in the connection string along with the parameter targetServerType=master, the connection pool is not created

    public Mutiny.SessionFactory getSessionFactory(@Qualifier("VertxMain") Vertx vertx) {
        Properties hiberProps = new Properties();
        hiberProps.put("jakarta.persistence.jdbc.url", "jdbc:postgresql://host1:5433,host2:5433/db?targetServerType=master");
        ...
        org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
        ...
        cfg.addProperties(hiberProps);

        Mutiny.SessionFactory sessionFactory =
                cfg.buildSessionFactory(new ReactiveServiceRegistryBuilder().applySettings(cfg.getProperties()).build())
                       .unwrap(Mutiny.SessionFactory.class);
        
        return sessionFactory;
    }

In such a configuration, the connection pool is not created:
Cannot invoke "io.vertx.sqlclient.Pool.getConnection()" because "pool" is null
In the interface SqlClientPoolConfiguration, the method connectOptions accepts a parameter of type URI, which comes from the setting jakarta.persistence.jdbc.url and assumes parsing only a single host value from the connection string.

How can I achieve a similar connection behavior in Hibernate Reactive as in Hibernate ORM, so that the connection is made specifically to the host that acts as a master in the cluster?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions