Close a Connection
Brought to you by:
hanzz,
markus-karg
Hi,
First of all, congratulation! it is difficult to find
free JCA 1.5 file system connectors, hope there will be
all the evolutions.
My problem is, there is no close methods in your
connection object, i can't understand how the container
can free a connection. (connections in use never decrease)
Here is my code :
DefaultFileResourceAdapterConnectionFactory
fileRAConnectionFactory =
(DefaultFileResourceAdapterConnectionFactory)
PortableRemoteObject.narrow(new
InitialContext().lookup("java:/fileRAAdapter"),
DefaultFileResourceAdapterConnectionFactory.class);
FileResourceAdapterConnection con =
fileRAConnectionFactory.getConnection();
System.out.println(con.existsFile("/tmp/lock"));
Thanks in advance,
Antoine Onnen
Logged In: YES
user_id=309221
Actually there is no "physical connection" if form of an
allocated IP port or something, so there is no actual need
to close a connection (if we would supply one, it wouldn't
do nothing at all). Is your container complaining about too
much open connections? What container are you using?
Logged In: YES
user_id=1267145
Hi,
I'm using jboss-4.0.0
this is my connector descriptor :
<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
<no-tx-connection-factory>
<jndi-name>fileRAAdapter</jndi-name>
<adapter-display-name>Local File System</adapter-display-name>
<min-pool-size>1</min-pool-size>
<max-pool-size>100</max-pool-size>
<rar-name>filera.rar</rar-name>
<connection-definition>net.sourceforge.filera.api.FileResourceAdapterConnectionFactory</connection-definition>
</no-tx-connection-factory>
</connection-factories>
You understand that if you do several getConnection in your
app without closing connection, the
DefaultFileResourceAdapterConnection objects created will
never be destruct, secondly even if you specify a timeout in
the descriptor, the container can't destructs connections.
See 6.5.1 of the JCA 1.5 spec :
"A Connection interface must provide a close method..."
I have not made the test but what append if there are
concurrential access to a file? Is there a pooling policy?
In 6.5.3.3 : "an application server should structure its
connection pool such that it uses the connection creation
and matching facility in an efficient manner and does not
cuase resource starvation"
Antoine Onnen
Logged In: YES
user_id=1267145
Are you still here?
Antoine Onnen
Logged In: YES
user_id=309221
I checked FileRA source code and JCA 1.5 specification. I
cannot see that FileRA has a bug here.
- "A connection interface must provide..." is only a guideline but
not a requirement of the specification. There actually is no
requirement that a close() method must exists in the Connection
interface.
- Connections do not get managed by the container but only
ManagedConnections. Connections are temporary handles that
get discarted once out of scope. The container only pools
ManagedConnections. Actually the container can just reuse the
connection that it has got and let it create a new connection
handle, since the connection gets shared. Maybe this is not
working with JBoss?
I will check the pooling and sharing behaviour tomorrow. It
would be great if you could check if it is really the Connection
but not the ManagedConnection that overflows.