[jboss-cvs] JBossAS SVN: r67542 - in branches/JBPAPP_4_2/server/src/main/org/jboss: jms/asf and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 28 00:43:04 EST 2007
Author: bdecoste
Date: 2007-11-28 00:43:04 -0500 (Wed, 28 Nov 2007)
New Revision: 67542
Modified:
branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvokerMBean.java
branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/ServerSessionPoolFactory.java
branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSession.java
branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSessionPool.java
branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSessionPoolFactory.java
Log:
[JBPAPP-456] fix for TIBCO EMS HA session recycle
Modified: branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
===================================================================
--- branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java 2007-11-28 05:41:42 UTC (rev 67541)
+++ branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java 2007-11-28 05:43:04 UTC (rev 67542)
@@ -145,7 +145,17 @@
/** If Dead letter queue should be used or not. */
protected boolean useDLQ = false;
+
+ /** The forceClearOnShutdown */
+ protected boolean forceClearOnShutdown = false;
+
+ /** The clearPoolInterval */
+ protected long forceClearInterval = 30000;
+
+ /** The forceClearAttempts */
+ protected int forceClearAttempts = 5;
+
/**
* JNDI name of the provider adapter.
*
@@ -264,7 +274,50 @@
{
this.maxMessagesNr = maxMessages;
}
+
+ public int getNumActiveSessions()
+ {
+ if (pool instanceof org.jboss.jms.asf.StdServerSessionPool)
+ {
+ org.jboss.jms.asf.StdServerSessionPool stdPool = (org.jboss.jms.asf.StdServerSessionPool)pool;
+ return stdPool.getNumActiveSessions();
+ }
+
+ return -1;
+ }
+
+ public void setForceClearOnShutdown(boolean forceClearOnShutdown)
+ {
+ this.forceClearOnShutdown = forceClearOnShutdown;
+ }
+
+ public boolean getForceClearOnShutdown()
+ {
+ return this.forceClearOnShutdown;
+ }
+
+ public long getForceClearOnShutdownInterval()
+ {
+ return this.forceClearInterval;
+ }
+
+ public void setForceClearOnShutdownInterval(long forceClearOnShutdownInterval)
+ {
+ this.forceClearInterval = forceClearOnShutdownInterval;
+ }
+
+ public int getForceClearAttempts()
+ {
+ return forceClearAttempts;
+ }
+
+ public void setForceClearAttempts(int forceClearAttempts)
+ {
+ this.forceClearAttempts = forceClearAttempts;
+
+ }
+
public MessageDrivenMetaData getMetaData()
{
MessageDrivenMetaData config =
@@ -435,9 +488,54 @@
catch (Exception ignore)
{
}
+
+ try
+ {
+ String forceClear = MetaData.getElementContent(MetaData.getUniqueChild(element, "ForceClearOnShutdown"));
+ if(forceClear != null)
+ {
+ forceClearOnShutdown = ("false".equalsIgnoreCase(forceClear)) ? false : true;
+
+ }
+
+ }catch(Exception ignore)
+ {
+
+ }
try
{
+ String clearInterval = MetaData.getElementContent(MetaData.getUniqueChild(element, "ForceClearInterval"));
+
+ if(clearInterval != null)
+ {
+ forceClearInterval = new Long(clearInterval).longValue();
+
+ }
+
+ }catch(Exception ignore)
+ {
+
+ }
+
+ try
+ {
+ String attempts = MetaData.getElementContent(MetaData.getUniqueChild(element, "ForceClearAttempts"));
+
+ if(attempts != null)
+ {
+ forceClearAttempts = new Integer(attempts).intValue();
+
+ }
+
+ }catch(Exception ignore)
+ {
+
+ }
+
+
+ try
+ {
String keepAliveMillis = MetaData.getElementContent
(MetaData.getUniqueChild(element, "KeepAliveMillis"));
keepAlive = Integer.parseInt(keepAliveMillis);
@@ -1235,8 +1333,8 @@
ServerSessionPoolFactory factory = (ServerSessionPoolFactory)
context.lookup(serverSessionPoolFactoryJNDI);
- // the create the pool
- pool = factory.getServerSessionPool(destination, connection, minSession, maxSession, keepAlive, isTransacted, ack, !isContainerManagedTx || isNotSupportedTx, listener);
+// the create the pool
+ pool = factory.getServerSessionPool(destination, connection, minSession, maxSession, keepAlive, forceClearOnShutdown, forceClearInterval, forceClearAttempts, isTransacted, ack, !isContainerManagedTx || isNotSupportedTx, listener);
}
finally
{
Modified: branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvokerMBean.java
===================================================================
--- branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvokerMBean.java 2007-11-28 05:41:42 UTC (rev 67541)
+++ branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvokerMBean.java 2007-11-28 05:43:04 UTC (rev 67542)
@@ -72,6 +72,55 @@
* @param keepAlive the milliseconds
*/
void setKeepAliveMillis(long keepAlive);
+
+ /**
+ * FIXME Comment this
+ *
+ * @return
+ */
+ boolean getForceClearOnShutdown();
+
+ /**
+ * FIXME Comment this
+ *
+ * @param forceClear
+ */
+ void setForceClearOnShutdown(boolean forceClear);
+
+ /**
+ * FIXME Comment this
+ *
+ * @return
+ */
+ long getForceClearOnShutdownInterval();
+
+ /**
+ * FIXME Comment this
+ *
+ * @param forceClearOnShutdownInterval
+ */
+ void setForceClearOnShutdownInterval(long forceClearOnShutdownInterval);
+
+ /**
+ * FIXME Comment this
+ *
+ * @return
+ */
+ int getForceClearAttempts();
+
+ /**
+ * FIXME Comment this
+ *
+ * @param forceClearAttempts
+ */
+ void setForceClearAttempts(int forceClearAttempts);
+
+ /**
+ * FIXME Comment this
+ *
+ * @return
+ */
+ int getNumActiveSessions();
/**
* Get the maximum number of messages
Modified: branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/ServerSessionPoolFactory.java
===================================================================
--- branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/ServerSessionPoolFactory.java 2007-11-28 05:41:42 UTC (rev 67541)
+++ branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/ServerSessionPoolFactory.java 2007-11-28 05:43:04 UTC (rev 67542)
@@ -77,6 +77,9 @@
* @param minSession the minimum number of sessions
* @param maxSession the maximum number of sessions
* @param keepAlive the time to keep sessions alive
+ * @param forceClear whether or not to force clearing the pool
+ * @param forceClearInterval the interval to wait between pool clearing attempts
+ * @param forceClearAttempts the number of attempts for clearing the pool
* @param isTransacted whether the pool is transacted
* @param ack the acknowledegement method
* @param listener the listener
@@ -85,6 +88,7 @@
* @throws JMSException for any error
*/
ServerSessionPool getServerSessionPool(Destination destination, Connection con, int minSession, int maxSession,
- long keepAlive, boolean isTransacted, int ack, boolean useLocalTX, MessageListener listener)
+ long keepAlive, boolean forceClear, long forceClearInterval, int forceClearAttempts,boolean isTransacted, int ack, boolean useLocalTX, MessageListener listener)
throws JMSException;
+
}
\ No newline at end of file
Modified: branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSession.java
===================================================================
--- branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSession.java 2007-11-28 05:41:42 UTC (rev 67541)
+++ branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSession.java 2007-11-28 05:43:04 UTC (rev 67542)
@@ -55,10 +55,10 @@
private StdServerSessionPool serverSessionPool;
/** Our session resource. */
- private Session session;
+ protected Session session;
/** Our XA session resource. */
- private XASession xaSession;
+ protected XASession xaSession;
/** The transaction manager that we will use for transactions. */
private TransactionManager tm;
@@ -103,7 +103,7 @@
* @param useLocalTX Will this session be used in a global TX (we can optimize with 1 phase commit)
* @throws JMSException Transation manager was not found.
*/
- StdServerSession(final StdServerSessionPool pool,
+ protected StdServerSession(final StdServerSessionPool pool,
final Session session,
final XASession xaSession,
final MessageListener delegateListener,
Modified: branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSessionPool.java
===================================================================
--- branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSessionPool.java 2007-11-28 05:41:42 UTC (rev 67541)
+++ branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSessionPool.java 2007-11-28 05:43:04 UTC (rev 67542)
@@ -70,41 +70,49 @@
private int minSize;
/** The size of the pool. */
- private int poolSize;
+ protected int poolSize;
/** The message acknowledgment mode. */
- private int ack;
+ protected int ack;
/** Is the bean container managed? */
- private boolean useLocalTX;
+ protected boolean useLocalTX;
/** True if this is a transacted session. */
- private boolean transacted;
+ protected boolean transacted;
/** The destination. */
- private Destination destination;
+ protected Destination destination;
/** The session connection. */
- private Connection con;
+ protected Connection con;
/** The message listener for the session. */
- private MessageListener listener;
+ protected MessageListener listener;
/** The list of ServerSessions. */
- private List sessionPool;
+ protected List sessionPool;
/** The executor for processing messages? */
private PooledExecutor executor;
/** Used to signal when the Pool is being closed down */
private boolean closing = false;
+
+ /** The forceClear */
+ private boolean forceClear = false;
+
+ /** The forceClearInterval */
+ private long forceClearInterval = 30000;
+
+ private int forceClearAttempts = 5;
/** Used during close down to wait for all server sessions to be returned and closed. */
- private int numServerSessions = 0;
+ protected int numServerSessions = 0;
- private XidFactoryMBean xidFactory;
+ protected XidFactoryMBean xidFactory;
- private TransactionManager tm;
+ protected TransactionManager tm;
/**
* Construct a <tt>StdServerSessionPool</tt>. Note the maxSession parameter controls
@@ -134,6 +142,9 @@
final int minSession,
final int maxSession,
final long keepAlive,
+ final boolean forceClear,
+ final long forceClearInterval,
+ final int forceClearAttempts,
final XidFactoryMBean xidFactory,
final TransactionManager tm)
throws JMSException
@@ -146,6 +157,9 @@
this.minSize = minSession;
this.poolSize = maxSession;
this.sessionPool = new ArrayList(maxSession);
+ this.forceClear = forceClear;
+ this.forceClearInterval = forceClearInterval;
+ this.forceClearAttempts = forceClearAttempts;
this.useLocalTX = useLocalTX;
this.xidFactory = xidFactory;
this.tm = tm;
@@ -210,6 +224,15 @@
log.trace("using server session: " + session);
return session;
}
+
+ /**
+ * Return number of active sessions. For use only for read-only jmx view.
+ * see JBPAPP-387
+ */
+ public int getNumActiveSessions()
+ {
+ return this.numServerSessions;
+ }
/**
* Clear the pool, clear out both threads and ServerSessions,
@@ -243,17 +266,41 @@
//Must be outside synchronized block because of recycle method.
executor.shutdownAfterProcessingCurrentlyQueuedTasks();
- //wait for all server sessions to be returned.
- synchronized (sessionPool)
+ int attempts = 0;
+ if(forceClear)
{
- while (numServerSessions > 0)
+ log.info("Force clear behavior in effect. Waiting for " + forceClearInterval + " milliseconds for " + forceClearAttempts + " attempts.");
+
+ while((numServerSessions > 0) && (attempts < forceClearAttempts))
{
try
{
- sessionPool.wait();
+ sessionPool.wait(forceClearInterval);
+ log.trace("Clear attempt " + attempts);
+ ++attempts;
+
+ }catch(InterruptedException ignore)
+ {
+
}
- catch (InterruptedException ignore)
+
+ }
+
+ }
+ else
+ {
+ //wait for all server sessions to be returned.
+ synchronized (sessionPool)
+ {
+ while (numServerSessions > 0)
{
+ try
+ {
+ sessionPool.wait();
+ }
+ catch (InterruptedException ignore)
+ {
+ }
}
}
}
@@ -310,7 +357,7 @@
}
}
- private void create() throws JMSException
+ protected void create() throws JMSException
{
for (int index = 0; index < poolSize; index++)
{
Modified: branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSessionPoolFactory.java
===================================================================
--- branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSessionPoolFactory.java 2007-11-28 05:41:42 UTC (rev 67541)
+++ branches/JBPAPP_4_2/server/src/main/org/jboss/jms/asf/StdServerSessionPoolFactory.java 2007-11-28 05:43:04 UTC (rev 67542)
@@ -47,9 +47,9 @@
/** The name of this factory. */
private String name;
- private XidFactoryMBean xidFactory;
+ protected XidFactoryMBean xidFactory;
- private TransactionManager transactionManager;
+ protected TransactionManager transactionManager;
public StdServerSessionPoolFactory()
{
@@ -86,9 +86,9 @@
return transactionManager;
}
- public ServerSessionPool getServerSessionPool(Destination destination, Connection con, int minSession, int maxSession, long keepAlive, boolean isTransacted, int ack, boolean useLocalTX, MessageListener listener) throws JMSException
+ public ServerSessionPool getServerSessionPool(Destination destination, Connection con, int minSession, int maxSession, long keepAlive, boolean forceClear, long forceClearInterval, int forceClearAttempts, boolean isTransacted, int ack, boolean useLocalTX, MessageListener listener) throws JMSException
{
- ServerSessionPool pool = new StdServerSessionPool(destination, con, isTransacted, ack, useLocalTX, listener, minSession, maxSession, keepAlive, xidFactory, transactionManager);
+ ServerSessionPool pool = new StdServerSessionPool(destination, con, isTransacted, ack, useLocalTX, listener, minSession, maxSession, keepAlive, forceClear, forceClearInterval, forceClearAttempts, xidFactory, transactionManager);
return pool;
}
}
More information about the jboss-cvs-commits
mailing list