Menu

#1 Close a Connection

open
None
1
2005-04-27
2005-04-26
FlatcH
No

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

Discussion

  • FlatcH

    FlatcH - 2005-04-27
    • priority: 5 --> 9
     
  • Markus KARG

    Markus KARG - 2005-04-27

    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?

     
  • Markus KARG

    Markus KARG - 2005-04-27
    • milestone: 479481 -->
     
  • Markus KARG

    Markus KARG - 2005-04-27
    • priority: 9 --> 1
    • assigned_to: nobody --> markus-karg
     
  • FlatcH

    FlatcH - 2005-04-28

    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

     
  • FlatcH

    FlatcH - 2005-05-03

    Logged In: YES
    user_id=1267145

    Are you still here?

    Antoine Onnen

     
  • Markus KARG

    Markus KARG - 2005-05-07

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.