-
1. Re: issues with JCA minimum connections
vickyk Feb 17, 2008 10:54 PM (in response to tvbinh)Couple of things we need to check
1) How are you getting the Connection Handle from the ConnectionFactory ? Are you passing the CRI details to the Connection Handle through the application code?
egDemoConnectionFactory cf = (DemoConnectionFactory)ctx.lookup("<JNDINAME>"); DemoConnectionHandle connection = cf.getConnection(parameter1, parameter2,......) ;
where getConnection(parameter1,parameter2,.....) contains the parameter which are used by ConnectionHandle implementation to generate the CRI object which is later passed to the ConnecitonManager Pool.
2) Verify if the <connectionfactory-impl-class> implementation are passsing the ConnectionRequestInfo appropriately when asked to .
Look at the jdbc resource adapter implemetaion of the connectionfactory-impl-class here
http://anonsvn.jboss.org/repos/jbossas/trunk/connector/src/main/org/jboss/resource/adapter/jdbc/WrapperDataSource.java
See how the WrappedConnectionRequestInfo is created in it and passed to ConnectionManager in itpublic Connection getConnection(String user, String password) throws SQLException { ConnectionRequestInfo cri = new WrappedConnectionRequestInfo(user, password); try { WrappedConnection wc = (WrappedConnection) cm.allocateConnection(mcf, cri); wc.setDataSource(this); return wc; } catch (ResourceException re) { throw new NestedSQLException(re); } }
-
2. Re: issues with JCA minimum connections
tvbinh Feb 18, 2008 1:09 AM (in response to tvbinh)Hi Vicky,
Thank you very much for your help,1) How are you getting the Connection Handle from the ConnectionFactory ? Are you passing the CRI details to the Connection Handle through the application code?
No, I declare all the properties in -ds.xml file e.g. and JBoss will read those. I prefer this way to hard coding properties into the codes. Below is the content of my -ds.xml
sampleds.xml<connection-factories> <no-tx-connection-factory> <jndi-name>SimplewireDS</jndi-name> <rar-name>65-mitto-ra-smpp.rar</rar-name> <connection-definition> com.smsc.mitto.ra.smpp.SMPPConnectionFactory </connection-definition> <config-property name="Name" type="java.lang.String">Mitto-1</config-property> <config-property name="Server" type="java.lang.String">192.168.2.115</config-property> <config-property name="Port" type="java.lang.Integer">9999</config-property> <config-property name="Username" type="java.lang.String">binh</config-property> <config-property name="Password" type="java.lang.String">binh</config-property> <min-pool-size>0</min-pool-size> <max-pool-size>4</max-pool-size> <idle-timeout-minutes>525600</idle-timeout-minutes> <!-- if idle for a year reconnect... --> <blocking-timeout-millis>100</blocking-timeout-millis> <prefill>true</prefill> </no-tx-connection-factory> </connection-factories>
The properties are loaded in my <managed-connection-factory> classpublic Object createConnectionFactory(ConnectionManager connectionManager) throws ResourceException { logger .info("Creating connection factory (with specified connectionmanager) in TelnetManagedConnectionfactory with id=" + id); // At this stage the values from the configuration file should have been // set if (server != null && port != 0 && username != null && password != null && name != null) { SMPPRequestInfo smppInfo; smppInfo = new SMPPRequestInfo(username, password, server, port, name); return new SMPPConnectionFactoryImpl(connectionManager, this, smppInfo); } else throw new ResourceException(); } public void setUsername(String username) { this.username = username; } public void setPassword(String password) { this.password = password; } public void setServer(String server) { this.server = server; } public void setPort(Integer port) { this.port = port; } public void setName(String name) { this.name = name; }
2/ Verify if the <connectionfactory-impl-class> implementation are passsing the ConnectionRequestInfo appropriately when asked to .
Since I declare all the properties in -ds.xml, I would probably not need to pass the ConnectionRequestInfo in my <connection-factory-impl> class. Here is the codes:
Look at the jdbc resource adapter implemetaion of the connectionfactory-impl-class herepublic SMPPConnection getConnection() throws NamingException { logger .info("Request an SMPPConnection from the SMPPConnectionFactoryImpl with id=" + id); SMPPConnectionImpl tc = null; try { tc = (SMPPConnectionImpl) manager.allocateConnection(factory, smppInfo); return tc; } catch (ResourceException ex) { // doing something } }
-
3. Re: issues with JCA minimum connections
vickyk Feb 18, 2008 1:37 AM (in response to tvbinh)try { tc = (SMPPConnectionImpl) manager.allocateConnection(factory, smppInfo); return tc; } catch (ResourceException ex) { // doing something
Put the log statement and see if the smppInfo does contain the values which you are passing from the the -ds.xml file .
If the log shows the values then it looks ok and you need to put some debugging in the org.jboss.resource to see where the CRI info is lost . -
4. Re: issues with JCA minimum connections
tvbinh Feb 18, 2008 6:06 PM (in response to tvbinh)Hi Vicky,
I don't have any problem with my <connection-factory-impl> class. It works nicely, I got all the properties that I want.
The problem is with JBoss loading the number of minimum connections as declared in -ds.xml file<connection-factories> <no-tx-connection-factory> <jndi-name>SimplewireDS</jndi-name> <rar-name>65-mitto-ra-smpp.rar</rar-name> <connection-definition> com.smsc.mitto.ra.smpp.SMPPConnectionFactory </connection-definition> <config-property name="Name" type="java.lang.String">Mitto-1</config-property> <config-property name="Server" type="java.lang.String">192.168.2.115</config-property> <config-property name="Port" type="java.lang.Integer">9999</config-property> <config-property name="Username" type="java.lang.String">binh</config-property> <config-property name="Password" type="java.lang.String">binh</config-property> <min-pool-size>2</min-pool-size> <max-pool-size>4</max-pool-size> <idle-timeout-minutes>525600</idle-timeout-minutes> <!-- if idle for a year reconnect... --> <blocking-timeout-millis>100</blocking-timeout-millis> <prefill>true</prefill> </no-tx-connection-factory> </connection-factories>
With the above xml, I expect JBoss to automatically create 2 fully functional connections to 192.168.2.115 for me using other connection request infor provided. Though, when I try to use these 2 connections, I always got null pointer exception.
I debuged through JBoss codes and found that JBoss does not make use of the connection request information also declared in the -ds.xml like server, port, username, password etc, when it tries to create connections to satisfy this minumum connection properties (it does load the property in) .... The problem lies in the fillToMin method of InternalManagedConnectionPool class of JBoss, where it uses null for ConnectionRequestInfo when trying to make the connections. Could you please check that for me ?
Thank you very much for your help,
Best regards,
Binh
----------
defaultCRI is null in the below codes
public void fillToMin() { while (true) { // Get a permit - avoids a race when the pool is nearly full // Also avoids unnessary fill checking when all connections are // checked out try { if (permits.attempt(poolParams.blockingTimeout)) { try { if (shutdown.get()) return; // We already have enough connections if (getMinSize() - connectionCounter.getGuaranteedCount() <= 0) return; // Create a connection to fill the pool try { ConnectionListener cl = createConnectionEventListener( defaultSubject, defaultCri); synchronized (cls) { if (trace) log.trace("Filling pool cl=" + cl); cls.add(cl); } } catch (ResourceException re) { log.warn("Unable to fill pool ", re); return; } } finally { permits.release(); } } } catch (InterruptedException ignored) { log.trace("Interrupted while requesting permit in fillToMin"); } } }
-
5. Re: issues with JCA minimum connections
adrian.brock Feb 20, 2008 10:31 AM (in response to tvbinh)As it says on the WIKI, prefill only works if you use the single pool option
which are using but should not.
If your MCF has a required CRI then JBoss doesn't know what that should be
(the contents are opaque to the connection manager - see the spec).
And as the FAQ says you should be using the "incorrectly named"<application-managed-security/>
if you have request parameters - a ConnectionRequestInfo (CRI).
The "workaround" is to tell it what the CRI is by programmatically
asking for a connection with the correct request parameters,
see the original feature request (also linked on the WIKI page describing the prefill option)
http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossJCAPooling