tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeankst <jean.kon-sun-t...@nielsen.com>
Subject Resource adapter / Connection / Binding / Pooling
Date Thu, 15 Feb 2018 14:57:23 GMT
Ok, here is what I got to work:

In ra.xml:

  <resourceadapter id="MyResourceAdapter">
    <resourceadapter-class>foo.bar.MyResourceAdapter</resourceadapter-class>
    <outbound-resourceadapter>
      <connection-definition id="MyConnectionFactory1">
       
<managedconnectionfactory-class>foo.bar.ManagedConnectionFactory</managedconnectionfactory-class>
        <config-property>
          <config-property-name>ServerName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
          <config-property-value>server001</config-property-value>
        </config-property>
        ...
      </connection-definition> 
      <connection-definition id="MyConnectionFactory2">
       
<managedconnectionfactory-class>foo.bar.ManagedConnectionFactory</managedconnectionfactory-class>
        <config-property>
          <config-property-name>ServerName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
          <config-property-value>server002</config-property-value>
        </config-property>
        ...
      </connection-definition> 
      ...        
    </outbound-resourceadapter>
  </resourceadapter>

On TomEE startup, in the logs, you should see:

  INFO [main]
org.apache.openejb.config.ConfigurationFactory.configureService Configuring
Service(id=MyResourceAdapter, type=Resource, provider-id=MyResourceAdapter)
  INFO [main]
org.apache.openejb.config.ConfigurationFactory.configureService Configuring
Service(id=MyConnectionFactory1, type=Resource,
provider-id=MyConnectionFactory1)
  INFO [main]
org.apache.openejb.config.ConfigurationFactory.configureService Configuring
Service(id=MyConnectionFactory2, type=Resource,
provider-id=MyConnectionFactory2)
  
So in a container managed bean, you can use:

  @Resource(name = "MyConnectionFactory1", authenticationType =
Resource.AuthenticationType.APPLICATION, shareable = true)
  private ConnectionFactory myFirstConnectionFactory;

  @Resource(name = "MyConnectionFactory2", authenticationType =
Resource.AuthenticationType.APPLICATION, shareable = true)
  private ConnectionFactory mySecondConnectionFactory;

In /conf/system.properties, we may set pooling parameters:

  MyResourceAdapter.threadPoolSize=7

  MyConnectionFactory1.pooling=true
  MyConnectionFactory1.poolMinSize=0
  MyConnectionFactory1.poolMaxSize=3
  MyConnectionFactory1.connectionMaxWaitTime=3 seconds
  MyConnectionFactory1.connectionMaxIdleTime=1 minutes

  MyConnectionFactory2.pooling=true
  MyConnectionFactory2.poolMinSize=1
  MyConnectionFactory2.poolMaxSize=2
  MyConnectionFactory2.connectionMaxWaitTime=5 seconds
  MyConnectionFactory2.connectionMaxIdleTime=10 seconds

What I understood:

- For Weblogic only a connection-definition is in ra.xml and
connection-instance(s) are in weblogic-ra.xml with the actual parameters and
pooling settings
- For TomEE all connections (and their paremeters) are defined in the sole
ra.xml; pooling (seems pooling=true by default) is however set in
system.properties

Question:

Is there a way do have those parameters embedded in the application EAR?
(instead of having to change the system.properties of the TomEE instance)
Is this possible using a resources.xml file? if so, what would be the syntax
to use according to the sample above?

Thanks,
Jean.





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html

Mime
View raw message