Can I / Should I pool neo4j's JDBC connections in Bolt mode? - jdbc

Reading the neo4j JDBC's documentation, there are two transports supported for connecting to a neo4j server at the moment:
through the Bolt protocol (3.0.X) using jdbc:neo4j:bolt://:/
through the HTTP protocol (2.X+) using jdbc:neo4j:http://:/
Obviously, the HTTP protocol does not need pooling connections (unless it's HTTP/2 which is not the case here). But I'm not familiar with Bolt so I'm wondering if I can pool neo4j's connections in Bolt mode? And if I can, is it like any ordinary JDBC connection and I can use, for example, HikariCP to keep its connections alive?

Neo4j driver handles for you a pool of connection to the database.
Take a look here if you want to see the default config : https://github.com/neo4j/neo4j-java-driver/blob/1.1/driver/src/main/java/org/neo4j/driver/internal/net/pooling/PoolSettings.java
For now, you can't configure the bolt java driver via the JDBC one, you can only specify the EncryptionLevel. (https://github.com/neo4j-contrib/neo4j-jdbc/blob/master/neo4j-jdbc-bolt/src/main/java/org/neo4j/jdbc/bolt/BoltDriver.java#L58-L60)
Cheers

Related

Kafka Connect JDBC Connector | Closing JDBC Connection after each poll

We are going to use use Kafka Connect JDBC Source Connector to ingest data from Oracle Databases.
We have one Kafka JDBC Connector per one Oracle Db.
Looking at the JDBC Connector implementation ,if we have N number of maxTasks per Connector (inside CachedConnectionProvider), there will be N number of JDBC Connections to the server.
These connections are kept alive and will not be closed after each poll().
Our DB Admins have strict conditions about number of live connections to the db servers.
Because of this, we are thinking of closing the JDBC Connection after each poll() since our poll times are usually 10 mins or more.
Is this supported natively by JDBC Connector or do we have to do a patch?

Pooled Connection Factory for ActiveMQ Artemis

Is there an equivalent to the ActiveMQ 5 PooledConnectionFactory for Artemis? Why is it available in one and not the other?
Spring, for example, offers a generic CachingConnectionFactory. This is great, but it implements the SingleConnectionFactory and only "pools" one connection.
It would be key to have a similar mechanism in the Artemis client that actually pooled greater than one connections.
Another thought is that maybe it's not implemented because a single connection supports concurrent sessions! I haven't tested the performance of a using a new connection per session. Is the performance the same or similar?
The PooledConnectionFactory in the ActiveMQ 5.x code-base is generic and can actually be used with ActiveMQ Artemis so there was no reason to port it into the Artemis code-base. That said, the JMS connection pool implementation has been pulled out of the ActiveMQ 5.x code-base, cleaned up, modified to support JMS 2, and made available here.
I'm not clear on what you mean by "concurrent sessions." Do you mean that the connection supports concurrently creating session or that the sessions themselves support concurrent use? The former is supported, but the latter is not.
In terms of performance, you'd have to benchmark your specific use-case. There are too many variables to simply say one is better than the other.

Jax rs client pool

I am working on setting up a REST Client using jax-rs 2 client API.
In the api doc it says "Clients are heavy-weight objects that manage the client-side communication infrastructure. Initialization as well as disposal of a Client instance may be a rather expensive operation. It is therefore advised to construct only a small number of Client instances in the application." (https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/Client.html). As per this statement it sounds like Client is not thread-safe and i should not be using single Client instance for all requests.
I am using CXF implementation, so far i didn't find a way to set up pool for Client objects.
If anyone has any information reg this could you please share.
Thanks in advance.
By default, CXF uses a transport based on the in-JDK HttpURLConnection object to perform HTTP requests.
Connection pooling is performed allowing persistent connections to reuse the underlying socket connection for multiple http requests.
Set these system properties to configure the pool(default values)
http.keepalive=true
http.maxConnections=5
Increment the value of http.maxConnections to set the maximum number of idle connections that will be simultaneously kept alive, per destination. See in this link the complete list of properties properties.html
In this post are explained some detail how it works
Java HttpURLConnection and pooling
Note also that the default JAX-RS client is not thread-safe by default. Check the limitations for proper use here
When you need many requests executed simultaneosly CXF can also use the asynchronous apache HttpAsyncClient. Ser details here
http://cxf.apache.org/docs/asynchronous-client-http-transport.html

MysqlConnectionPoolDataSource or c3p0 like library?

What's the difference between MysqlConnectionPoolDataSource and C3p0, BoneCP or dbcp library for connection pooling? I don't understand why use a library if mysql connector give connection pooling.
A ConnectionPoolDataSource is not a connection pool (or at least: it shouldn't be), it is intended to be used by a DataSource that provides pooling (eg from an application server). A ConnectionPoolDataSource provides the physical connections that will be held in the connection pool. Besides creating those physical connections a ConnectionPoolDataSource shouldn't do anything else.
So if you are working in an application server, use the pooling provided by the DataSources of the application server. If you are in a standalone application or a server that doesn't provide datasources on its own, use third party connection pools like BoneCP, c3p0 or Apache DBCP. If MySQL also provides a normal DataSource that provides pooling, then you could use that.

number of live connections

My application is using Websphere 6.1, Spring JDBC and oracle.I am using connection pooling to manage the connections.Is there any way to find out the number of connections active(alive) between the application and database at any point of time?.Can we have any indicator to let us know when a connection is/was dropped?
One option would be to manage your connection pool via JMX. Spring has excellent support for it. You just need to expose your connection pool bean via org.springframework.jmx.export.MBeanExporter. You can pick and choose the methods you want to expose. For example if you use DBCP you can use the method BasicDataSource#getNumActive().

Resources