User: pra
Date: 01/02/28 01:25:45
Modified: src/main/org/jboss/jms/asf StdServerSession.java
StdServerSessionPool.java
StdServerSessionPoolFactory.java
Log:
MDB deployment descriptor now follows the latest EJB2.0 DTD; code clean up done;
message receipt now allways transacted
Revision Changes Path
1.3 +71 -70 jboss/src/main/org/jboss/jms/asf/StdServerSession.java
Index: StdServerSession.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/StdServerSession.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StdServerSession.java 2001/01/08 21:57:08 1.2
+++ StdServerSession.java 2001/02/28 09:25:43 1.3
@@ -81,7 +81,7 @@
public void start()
throws JMSException
{
- Logger.debug("Start invokes on server session");
+ //Logger.debug("Start invokes on server session");
if ( session != null) {
serverSessionPool.getThreadPool().run(this);
}
@@ -97,16 +97,16 @@
* to the session to have been filled with messages and it will run
* against the listener set in StdServerSessionPool. When it has send
* all its messages it returns.
- *
- * HC: run() also starts a transaction with the TransactionManager and
- * enlists the XAResource of the JMS XASession if a XASession was abvailable.
- * A good JMS implementation should provide the XASession for use in the ASF.
- * So we optimize for the case where we have an XASession. So, for the case
- * where we do not have an XASession and the bean is not transacted, we
- * have the unneeded overhead of creating a Transaction. I'm leaving it
- * this way since it keeps the code simpler and that case should not be too
- * common (spyderMQ provides XASessions).
- *
+ *
+ * HC: run() also starts a transaction with the TransactionManager and
+ * enlists the XAResource of the JMS XASession if a XASession was abvailable.
+ * A good JMS implementation should provide the XASession for use in the ASF.
+ * So we optimize for the case where we have an XASession. So, for the case
+ * where we do not have an XASession and the bean is not transacted, we
+ * have the unneeded overhead of creating a Transaction. I'm leaving it
+ * this way since it keeps the code simpler and that case should not be too
+ * common (JBossMQ provides XASessions).
+ *
*/
public void run() {
@@ -114,82 +114,83 @@
try {
- Logger.debug("Invoking run on session");
-
- Logger.debug("Starting the Message Driven Bean transaction");
- tm.begin();
- trans = tm.getTransaction();
-
- if( xaSession != null ) {
-
+ //Logger.debug("Invoking run on session");
+
+ //Logger.debug("Starting the Message Driven Bean transaction");
+ tm.begin();
+ trans = tm.getTransaction();
+
+ if( xaSession != null ) {
+
XAResource res = xaSession.getXAResource();
trans.enlistResource(res);
- Logger.debug("XAResource '"+res+"' enlisted.");
-
- }
-
+ //Logger.debug("XAResource '"+res+"' enlisted.");
+
+ }
+
session.run();
-
+
}catch (Exception ex) {
-
- Logger.exception( ex );
-
- try {
- // The transaction will be rolledback in the finally
- trans.setRollbackOnly();
- } catch( Exception e ) {
- Logger.exception( e );
- }
-
+
+ Logger.exception( ex );
+
+ try {
+ // The transaction will be rolledback in the finally
+ trans.setRollbackOnly();
+ } catch( Exception e ) {
+ Logger.exception( e );
+ }
+
} finally {
-
-
- try {
-
- Logger.debug("Ending the Message Driven Bean transaction");
-
+
+
+ try {
+
+ //Logger.debug("Ending the Message Driven Bean transaction");
+
// Marked rollback
if ( trans.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
-
- // actually roll it back
- trans.rollback();
-
- // NO XASession? then manually rollback. This is not
so good but
- // it's the best we can do if we have no XASession.
- if( xaSession==null &&
serverSessionPool.isTransacted() )
- session.rollback();
-
+ Logger.log("Rolling back JMS transaction");
+ // actually roll it back
+ trans.rollback();
+
+ // NO XASession? then manually rollback.
+ // This is not so good but
+ // it's the best we can do if we have no XASession.
+ if( xaSession==null && serverSessionPool.isTransacted() )
+ session.rollback();
+
} else if(trans.getStatus() == Status.STATUS_ACTIVE) {
-
- // Commit tx
- // This will happen if
- // a) everything goes well
- // b) app. exception was thrown
-
- trans.commit();
-
- // NO XASession? then manually commit. This is not so
good but
- // it's the best we can do if we have no XASession.
- if( xaSession==null &&
serverSessionPool.isTransacted() )
- session.commit();
-
+
+ // Commit tx
+ // This will happen if
+ // a) everything goes well
+ // b) app. exception was thrown
+
+ trans.commit();
+
+ // NO XASession? then manually commit. This is not so good but
+ // it's the best we can do if we have no XASession.
+ if( xaSession==null && serverSessionPool.isTransacted() )
+ session.commit();
+
}
-
- } catch(Exception e) {
- // There was a problem doing the commit/rollback.
- Logger.exception(e);
- }
-
+
+ } catch(Exception e) {
+ // There was a problem doing the commit/rollback.
+ Logger.exception(e);
+ }
+
StdServerSession.this.recycle();
}
}
-
+
/**
* This method is called by the ServerSessionPool when it is ready to
* be recycled intot the pool
*/
void recycle()
{
- serverSessionPool.recycle(this);
+ serverSessionPool.recycle(this);
}
} // StdServerSession
1.3 +14 -22 jboss/src/main/org/jboss/jms/asf/StdServerSessionPool.java
Index: StdServerSessionPool.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/StdServerSessionPool.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StdServerSessionPool.java 2001/01/08 21:57:08 1.2
+++ StdServerSessionPool.java 2001/02/28 09:25:44 1.3
@@ -55,34 +55,26 @@
private ThreadPool threadPool = new ThreadPool();
private Vector sessionPool = new Vector();
- boolean isTransacted() {
- return transacted;
- }
-
-
+ boolean isTransacted() {
+ return transacted;
+ }
+
+
/**
* Minimal constructor, could also have stuff for pool size
*/
public StdServerSessionPool(Connection con, boolean transacted, int ack,
MessageListener listener) throws JMSException{
this(con,transacted,ack,listener,DEFAULT_POOL_SIZE);
- /*
- this.ack = ack;
- this.listener = listener;
- this.transacted = transacted;
- threadPool.setMaximumSize(poolSize);
-
- init();
- */
}
- public StdServerSessionPool(Connection con, boolean transacted, int ack,
MessageListener listener, int maxSession) throws JMSException{
- this.con = con;
- this.ack = ack;
- this.listener = listener;
- this.transacted = transacted;
- this.poolSize = maxSession;
- threadPool.setMaximumSize(poolSize);
- init();
- Logger.debug("Server Session pool set up");
+ public StdServerSessionPool(Connection con, boolean transacted, int ack,
MessageListener listener, int maxSession) throws JMSException{
+ this.con = con;
+ this.ack = ack;
+ this.listener = listener;
+ this.transacted = transacted;
+ this.poolSize = maxSession;
+ threadPool.setMaximumSize(poolSize);
+ init();
+ Logger.debug("Server Session pool set up");
}
// --- JMS API for ServerSessionPool
1.2 +1 -16
jboss/src/main/org/jboss/jms/asf/StdServerSessionPoolFactory.java
Index: StdServerSessionPoolFactory.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/StdServerSessionPoolFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StdServerSessionPoolFactory.java 2000/12/27 22:45:54 1.1
+++ StdServerSessionPoolFactory.java 2001/02/28 09:25:44 1.2
@@ -44,23 +44,8 @@
public String getName(){return name;}
public ServerSessionPool getServerSessionPool(Connection con, int maxSession,
boolean isTransacted, int ack, MessageListener listener) throws JMSException {
- /*
- This is probably basically fucked up. The ServerSessionPool in
- OpenJMS is a Singleton. Every one that uses it will end up in
- the same Connection and against the same messagelistener.
- */
-
- // We need a pool, but what should we key on, a guess the adress
- // of the listener is the only really uniqe here
- String key = listener.toString();// Or hash?
-
- if (pools.containsKey(key)) {
- return (ServerSessionPool)pools.get(key);
- } else {
-
ServerSessionPool pool = (ServerSessionPool)new StdServerSessionPool(con,
isTransacted, ack, listener,maxSession);
- pools.put(key, pool);
return pool;
- }
+ //}
}
} // StdServerSessionPoolFactory