which connection pool to use with JPA/Toplink implementation in J2EE? - jpa

I have J2EE Application where I am using JPA/Toplink now I want to implement external or internal connection pool ... please help me to figure out how to implement connection pooling with JPA/TopLink ...

Well you shouldn't implement a connection pool yourself.
If your app is running inside an app server (JBoss, Glassfish..) your JPA code will use the connection pools that are configured by the app server. If you are running standalone you can use any of the number of existing open source connection pool implementations such as DBCP.

I agree with Gregory, you don't want to write a connection pool yourself. Have a look at e.g. Proxool or Commons DBCP which are both well-tested opensource connection pools.
Proxool, in my opinion, has the advantage of being trivial to add to an existing project.

Related

ADO.NET background pool validation

in Java, application servers like JBoss EAP have the option to periodically verify the connections in a database pool (https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html/administration_and_configuration_guide/sect-database_connection_validation). This has been very useful for removing stale connections.
I'm now looking at a ADO.NET application, and I was wondering if there was any similar functionality that could be used with a Microsoft SQL Server?
I ended up find this post by redgate that describes some of the validation that goes on when connections are taken from the pool:
If the connection has died because a router has decided that it no
longer wants to forward your packets and no other routers like you
either then there is no way to know this unless you try to send some
data and don’t get a response.
If you create a connection and a connection pool is created and
connections are put into the pool and not used, the longer they are in
there, the bigger the chance of something bad happening to it.
When you go to use a connection there is nothing to warn you that a
router has stopped forwarding your packets until you go to use it; so
until you use it, you do not know that there is a problem.
This was an issue with connection pooling that was fixed in the first
.Net 4 reliability update (see issue 14 which vaguely describes this)
with a feature called “Connection Pool Resiliency”. The update meant
that when a connection is about to be taken from the pool, it is
checked for TCP validity and only returned if it is in a good state.

mongodb connection pool with authenticated connections in C++ driver

I've read that the connection pool of the C++ driver doesn't work with authenticated connections (article from end of 2013).
Is this (still) true?
Looking the documentation regarding the new C++ driver (named "legacy"), it seems that the relevant classes has been removed:
The ConnectionPool and ScopedDbConnection classes have been removed.
So the situation is even worse: not only the driver doesn't provide any mechanism for implement connections pools with authentication... it doesn't provide any pool connection mechanism at all :(
The rationale is detailed in this issue at MongoDB JIRA:
At this time, we have no plans to add pooling back into the legacy driver for the upcoming 1.0 release. It should be very straightforward to implement a simple pool for your application, and you will have one that does exactly what you want

flask postgresql connection pool using uwsgi to run behind nginx

I'm relatively new to web servers and web applications.
We have a basic python application implemented on flask which was deployed on the server using uwsgi to run behind nginx server. Currently our app has to create a postgreSQL db connection on every requests which takes more than ideal time. What I need is a persistent connection pool which will be created only once and reused on each request.
I tried to create a connection pool using pssycopg2 built-in functionality
# create pool with min number of connections of 1, max of 10
a = psycopg2.pool.SimpleConnectionPool(1,10,database='YOURDB', otherstuff...)
But Couldn't get a global persistent connection pool to be used, when processing a request, may be because of UWSGI.
I looked up connection pooling with flask UWSGI but couldn't find sufficient information to create connection pools
Question 1: How or what is the best way to implement connection pooling in such an environment mentioned above (flask + UWSGI + NGINX)?
Question 2: If I implement an ORM like SQL-Alchemy. Will that be able to provide efficient connection pooling in the above case or will UWSGI block its capabilities to provide a connection pool?
There are a few PostgreSQL pooling options:
pgpool
PgBouncer
psycopg2.pool
I'm using psycopg2.pool.ThreadedConnectionPool with a small Flask app and it is working fine.
connection_pool = pool.ThreadedConnectionPool(MINCONN, MAXCONN, database=DB, user=USER, password=PASSWORD)
conn = connection_pool.getconn()
# use conn, then:
connection_pool.putconn(conn)
It's up to you to handle what happens when the pool is full, as getconn() doesn't block.

Get HTTP connection pool from Websphere 6.1

All
I am making REST client calls from an EJB container (IBM Websphere v6.1) and cannot find any way to get a HTTP connection factory from WAS.
Is this possible in WAS 6.1?
Would expect be able to access this with JNDI so connection pool configuration, socket timeout, connection timeout, connections per URL etc could be centrally managed.
If not the alternative is to use a Client API such as HttpClient 4.3. But this has its own kettle of fish:
They recommend 'BasicHttpClientConnectionManager': "This connection manager implementation should be used inside an EJB container". However this implies one connection per thread which in an application with many threads will exhaust the resources of the O/S.
The other alternative 'PoolingHttpClientConnectionManager' seems to be a much better fit with much of the required controls, but in the the comments on the the Basic manager it says explicitly that the Pooling manager shouldn't be used in a EJB container managed context. Scanning the code for this it looks like the Pooling manager uses Future from the concurrent library but doesn't appear to directly use Threads.
Any suggestions about the best way forward would be appreciated - some options seem to be:
Test with PoolingHttpClientConnectionManager - with risk of subtle problems
Play safe with 'BasicHttpClientConnectionManager' but set short response and socket timeouts to constrain the number of concurrent sockets at the cost of lots of factory overhead. Yuk.
Some other way of getting access to the pool of HTTP connections in WAS 6.1.
Something else
Any suggestions for this rather ikky problem would be ideal.
Please don't suggest upgrading WAS - although future versions ie the WAS commerce version do seem to have a JCA HTTP Adaptor and 8.5 has a built in REST client.
Please don't publish responses relating to MQ/JMS, JDBC connection pooling or setting up resource adaptors for EIS other than HTTP.

I want to make an UDP server/listener that runs in JBoss

I have to implement software that listens for UDP packets and persists their contents to a database.
It would be handy if this could run in JBoss, as this is the infrastructure we are using now.
I have seen that Netty is ideally suited to program the listener part.
Is there a way to use Netty "embedded" in JBoss? I have searched up and down the Net and the examples I have found are all for standalone listener programs.
Of course, but you have to clarify what you mean by ""embedded" in JBoss". If you are writing a standard EJB application, just put Netty bootstrap code in #PostConstruct of singleton session bean and destroy it in #PreDestroy.
If it's a web application, use any servlet's init() method (servlet must be created eagerly on startup).
Note that EJB spec does not allow creating custom threads and listening on arbitrary ports - Netty violates both of these requirements. But JBoss won't enforce this.
Sounds like JCA might be the appropriate path.