Setting TCPNODELAY on Oracle XA datasource in JBOSS

While troubleshooting performance problems, we wanted to test disabling Nagle’s algorithm in JBOSS with an Oracle XA datasource. We found that property was not configurable in the regular Oracle XA class.

We ended up extending the Oracle class to set the property, using what is below.

package com.express.infra.jdbc;

import oracle.jdbc.xa.client.*;
import java.sql.*;
import javax.sql.*;
import java.util.*;

public class oracleXADriver extends oracle.jdbc.xa.client.OracleXADataSource {
  String tcpNoDelay;
  public oracleXADriver() throws SQLException {
    System.out.println("created com.express.infra.jdbc.oracleXADriver instance.");
  }

  public XAConnection getXAConnection(Properties properties) throws SQLException {
    //uncomment to debug, but the properties will show the decrypted password in the server log
    /*
    System.out.println("getting connection with " + getTcpNoDelay() + " for a tcpNoDelay value.");
    System.out.println(properties.toString());
    /*
    properties.setProperty("oracle.jdbc.TcpNoDelay",getTcpNoDelay());
    return (XAConnection)getPooledConnection(properties);
  }

  public String getTcpNoDelay () {
    return this.tcpNoDelay;
  }

  public void setTcpNoDelay (String value) {
    this.tcpNoDelay = value;
  }
}

We compiled this class and put it in a jarfile, placed it in the JBOSS_HOME/server/your_server_name/lib directory, and edited the ds.xml file to reflect our jar and the tcpNoDelay property, shown below…

        
                atgcatalogroa_ds
                com.express.infra.jdbc.oracleXADriver
                jdbc:oracle:thin:@//host:port/service_name
                true



        

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.