dbcp.BasicDataSource - MBeanExporter - dataSourceMBean

db.test.on.borrow=true
db.min.idle=2
db.max.idle=-1
db.max.active=90
db.min.evict=60000
db.evict.frequency=6000

<bean id="dataSourceMBean" class="com.qbw.utilities.BasicDataSourceMBean">           
  <constructor-arg ref="dataDataSource" />
</bean>
 <bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter">
      <property name="beans">
            <map>
                 <entry key="DBCP:name=dataDataSource" value-ref="dataSourceMBean" />
            </map>
      </property>
</bean>

package com.qbw.tr.web.utilities;

import java.sql.SQLException;
import org.apache.commons.dbcp.BasicDataSource;
public class BasicDataSourceMBean {
 private BasicDataSource dataSource;
 public BasicDataSourceMBean(BasicDataSource dataSource) {
  this.dataSource = dataSource;
 }
 /**
  * The current number of active connections allocated from the managed datasource.
  * @return  The current number of active connections
  */
 public int getNumActive() {
  return dataSource.getNumActive();
 }

 /**
  * The current number of idle connections waiting to be allocated from the managed datasource.
  * @return  The current number of active connections
  */
 public int getNumIdle() {
  return dataSource.getNumIdle();
 }
 /**
  * <p>Returns the maximum number of active connections that can be allocated at the same time.
  * </p>
  * <p>A negative number means that there is no limit.</p>
  *
  * @return the maximum number of active connections
  */
 public int getMaxActive() {
  return dataSource.getMaxActive();
 }
 /**
  * Sets the maximum number of active connections that can be
  * allocated at the same time. Use a negative value for no limit.
  *
  * @param maxActive the new value for maxActive
  */
 public void setMaxActive(int maxActive) {
  dataSource.setMaxActive(maxActive);
 }

 /**
  * <p>Returns the maximum number of connections that can remain idle in the pool.</p>
  * <p>A negative value indicates that there is no limit</p>
  *
  * @return the maximum number of idle connections
  */
 public  int getMaxIdle() {
  return dataSource.getMaxIdle();
 }
 /**
  * Sets the maximum number of connections that can remain idle in the pool.
  *
  * @param maxIdle the new value for maxIdle
  */
 public  void setMaxIdle(int maxIdle) {
  dataSource.setMaxIdle(maxIdle);
 }

 /**
  * Returns the minimum number of idle connections in the pool.
  *
  * @return the minimum number of idle connections
  *
  */
 public  int getMinIdle() {
  return dataSource.getMinIdle();
 }
 /*
  * Sets the minimum number of idle connections in the pool.
  *
  * @param minIdle the new value for minIdle
  *
  */
 public  void setMinIdle(int minIdle) {
  dataSource.setMinIdle(minIdle);
 }
 /**
  * <p>Sets the maxWait property.</p>
  * <p>Use -1 to make the pool wait indefinitely.</p>
  *
  * @param maxWait the new value for maxWait
  * @see #getMaxWait()
  */
 public  void setMaxWait(long maxWait) {
  dataSource.setMaxWait(maxWait);
 }

 public long getMaxWait() {
  return dataSource.getMaxWait();
 }
 public long getMinEvictableIdleTimeMillis() {
  return dataSource.getMinEvictableIdleTimeMillis();
 }
 public void setMinEvictableIdleTimeMillis(long val) {
  dataSource.setMinEvictableIdleTimeMillis(val);
 }
 public void setMaxOpenPreparedStatements(int val) {
  dataSource.setMaxOpenPreparedStatements(val);
 }
 public long getMaxOpenPreparedStatements() {
  return dataSource.getMaxOpenPreparedStatements();
 }
 public void setLoginTimeout(int val) throws SQLException {
  dataSource.setLoginTimeout(val);
 }
 public int getLoginTimeout() throws SQLException {
  return dataSource.getLoginTimeout();
 }
 public void setPoolPreparedStatements(boolean val) {
  dataSource.setPoolPreparedStatements(val);
 }
 public boolean isPoolPreparedStatements() {
  return dataSource.isPoolPreparedStatements();
 }
 
 public void setNumTestsPerEvictionRun(int val) {
  dataSource.setNumTestsPerEvictionRun(val);
 }
 public int getNumTestsPerEvictionRun() {
  return dataSource.getNumTestsPerEvictionRun();
 }
 public void setTestOnBorrow(boolean val) {
  dataSource.setTestOnBorrow(val);
 }
 public boolean getTestOnBorrow() {
  return dataSource.getTestOnBorrow();
 }
 public void setTestOnReturn(boolean val) {
  dataSource.setTestOnReturn(false);
 }
 public boolean getTestOnReturn() {
  return dataSource.getTestOnReturn();
 }
 public void setTestWhileIdle(boolean val) {
  dataSource.setTestWhileIdle(val);
 }
 public boolean getTestWhileIdle() {
  return dataSource.getTestWhileIdle();
 }
 
 public void setTimeBetweenEvictionRunsMillis(long val) {
  dataSource.setTimeBetweenEvictionRunsMillis(val);
 }
 public long getTimeBetweenEvictionRunsMillis() {
  return dataSource.getTimeBetweenEvictionRunsMillis();
 }
 public int getCurrentPoolSize() {
  return getNumActive()+getNumIdle();
 }
}
 

Keywords:

Filed Under: Java

Master/Slave notes.

http://activemq.apache.org/jdbc-master-slave.html

  <!-- Oracle DataSource Sample Setup -->
  <!--
  <bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="url" value="jdbc:oracle:thin:@localhost:1521:AMQDB"/>
    <property name="username" value="scott"/>
    <property name="password" value="tiger"/>
    <property name="poolPreparedStatements" value="true"/>
  </bean>
  -->
 
 
 <!-- The store and forward broker networks ActiveMQ will listen to -->
    <networkConnectors>
      <networkConnector name="HA Queue"
          uri="static://(tcp://10.0.1.199:61616,tcp://10.0.1.219:61616)" />
    </networkConnectors>


 
 ***DAQ***  OpenWire is for c++, Java and .NET.
  failover:(tcp://broker1:61616,tcp://broker2:61616)?initialReconnectDelay=100,?randomize=false


Manning Example URI
failover:(tcp://localhost:61616,tcp://remotehost:61616)?initialReconnectDelay=100

If the above gives errors try it this way (this way works in ActiveMQ 4.1.1 the one above does not)
failover://(tcp://localhost:61616,tcp://remotehost:61616)?initialReconnectDelay=100


 
  Sample program and config of M/S amq.
  http://osdir.com/ml/java.activemq.user/2006-05/msg00031.html
 
 
  http://servicemix.apache.org/clustering.html

Keywords:

Filed Under: Active MQ

Spring - Tomcat 404/exception processing

Keywords:

Filed Under: Spring · Tomcat

TextBox widget example - adding any formatted HTML code to the widget.

Comment List

  • None

Month List