activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r735914 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/ activemq-ra/src/main/java/org/apache/activemq/ra/
Date Tue, 20 Jan 2009 02:13:31 GMT
Author: djencks
Date: Mon Jan 19 18:13:31 2009
New Revision: 735914

URL: http://svn.apache.org/viewvc?rev=735914&view=rev
Log:
AMQ-2079 improve error messages in AMQConnection.createSession, and make ManagedConnectionProxy
only supply consistent parameters

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
    activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java?rev=735914&r1=735913&r2=735914&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnection.java
Mon Jan 19 18:13:31 2009
@@ -297,8 +297,13 @@
     public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
{
         checkClosedOrFailed();
         ensureConnectionInfoSent();
-        if(!transacted && acknowledgeMode==Session.SESSION_TRANSACTED) {
-           throw new JMSException("acknowledgeMode SESSION_TRANSACTED cannot be used for
an non-transacted Session");
+        if(!transacted) {
+            if (acknowledgeMode==Session.SESSION_TRANSACTED) {
+                throw new JMSException("acknowledgeMode SESSION_TRANSACTED cannot be used
for an non-transacted Session");
+            } else if (acknowledgeMode < Session.SESSION_TRANSACTED || acknowledgeMode
> ActiveMQSession.MAX_ACK_CONSTANT) {
+                throw new JMSException("invalid acknowledgeMode: " + acknowledgeMode + ".
Valid values are Session.AUTO_ACKNOWLEDGE (1), " +
+                        "Session.CLIENT_ACKNOWLEDGE (2), Session.DUPS_OK_ACKNOWLEDGE (3),
ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE (4) or for transacted sessions Session.SESSION_TRANSACTED
(0)");
+            }
         }
         return new ActiveMQSession(this, getNextSessionId(), transacted ? Session.SESSION_TRANSACTED
: (acknowledgeMode == Session.SESSION_TRANSACTED
             ? Session.AUTO_ACKNOWLEDGE : acknowledgeMode), isDispatchAsync(), isAlwaysSessionAsync());

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java?rev=735914&r1=735913&r2=735914&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java Mon
Jan 19 18:13:31 2009
@@ -140,6 +140,7 @@
 	 * is called
 	 */
     public static final int INDIVIDUAL_ACKNOWLEDGE = 4;
+    public static final int MAX_ACK_CONSTANT = INDIVIDUAL_ACKNOWLEDGE;
 
     public static interface DeliveryListener {
         void beforeDelivery(ActiveMQSession session, Message msg);

Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java?rev=735914&r1=735913&r2=735914&view=diff
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java
(original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java
Mon Jan 19 18:13:31 2009
@@ -84,7 +84,9 @@
     }
 
     /**
-     * 
+     *
+     * @return "physical" underlying activemq connection, if proxy is associated with a managed
connection
+     * @throws javax.jms.JMSException if managed connection is null
      */
     private Connection getConnection() throws JMSException {
         if (managedConnection == null) {
@@ -94,22 +96,26 @@
     }
 
     /**
-     * @param transacted
-     * @param acknowledgeMode
-     * @return
-     * @throws JMSException
+     * @param transacted Whether session is transacted
+     * @param acknowledgeMode session acknowledge mode
+     * @return session proxy
+     * @throws JMSException on error
      */
     public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
{
         return createSessionProxy(transacted, acknowledgeMode);
     }
 
     /**
-     * @param acknowledgeMode
-     * @param transacted
-     * @return
-     * @throws JMSException
+     * @param transacted Whether session is transacted
+     * @param acknowledgeMode session acknowledge mode
+     * @return session proxy
+     * @throws JMSException on error
      */
     private ManagedSessionProxy createSessionProxy(boolean transacted, int acknowledgeMode)
throws JMSException {
+        if (!transacted && acknowledgeMode == Session.SESSION_TRANSACTED) {
+            acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
+        }
+//        ActiveMQSession session = (ActiveMQSession)getConnection().createSession(true,
acknowledgeMode);
         ActiveMQSession session = (ActiveMQSession)getConnection().createSession(transacted,
acknowledgeMode);
         ManagedTransactionContext txContext = new ManagedTransactionContext(managedConnection.getTransactionContext());
         session.setTransactionContext(txContext);
@@ -120,27 +126,26 @@
     }
 
     public void setUseSharedTxContext(boolean enable) throws JMSException {
-        for (Iterator<ManagedSessionProxy> iter = sessions.iterator(); iter.hasNext();)
{
-            ManagedSessionProxy p = iter.next();
+        for (ManagedSessionProxy p : sessions) {
             p.setUseSharedTxContext(enable);
         }
     }
 
     /**
-     * @param transacted
-     * @param acknowledgeMode
-     * @return
-     * @throws JMSException
+     * @param transacted Whether session is transacted
+     * @param acknowledgeMode session acknowledge mode
+     * @return session proxy
+     * @throws JMSException on error
      */
     public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws
JMSException {
         return new ActiveMQQueueSession(createSessionProxy(transacted, acknowledgeMode));
     }
 
     /**
-     * @param transacted
-     * @param acknowledgeMode
-     * @return
-     * @throws JMSException
+     * @param transacted Whether session is transacted
+     * @param acknowledgeMode session acknowledge mode
+     * @return session proxy
+     * @throws JMSException on error
      */
     public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws
JMSException {
         return new ActiveMQTopicSession(createSessionProxy(transacted, acknowledgeMode));



Mime
View raw message