You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2016/06/07 12:54:58 UTC

svn commit: r1747212 - in /qpid/java/trunk: client/src/main/java/org/apache/qpid/client/ client/src/main/java/org/apache/qpid/jms/ common/src/main/java/org/apache/qpid/configuration/ doc/jms-client-0-10/src/docbkx/ doc/jms-client-0-8/src/docbkx/

Author: kwall
Date: Tue Jun  7 12:54:58 2016
New Revision: 1747212

URL: http://svn.apache.org/viewvc?rev=1747212&view=rev
Log:
QPID-7274: [Java Client] Allow sync after message acknowledge on client_ack session to be suppressed

Modified:
    qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java
    qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
    qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java
    qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
    qpid/java/trunk/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
    qpid/java/trunk/doc/jms-client-0-10/src/docbkx/JMS-Client-0-10-Book.xml
    qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml
    qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-System-Properties.xml

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java?rev=1747212&r1=1747211&r2=1747212&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java Tue Jun  7 12:54:58 2016
@@ -204,6 +204,9 @@ public class AMQConnection extends Close
     //Indicates whether we need to sync on every message ack
     private boolean _syncAck;
 
+    //Indicates whether we need to sync on every message ack on a client ack session, default to true
+    private final boolean _syncClientAck;
+
     //Indicates the sync publish options (persistent|all)
     //By default it's async publish
     private String _syncPublish = "";
@@ -342,6 +345,22 @@ public class AMQConnection extends Close
             _syncAck = Boolean.getBoolean(ClientProperties.SYNC_ACK_PROP_NAME);
         }
 
+        if (connectionURL.getOption(ConnectionURL.OPTIONS_SYNC_CLIENT_ACK) != null)
+        {
+            _syncClientAck = Boolean.parseBoolean(connectionURL.getOption(ConnectionURL.OPTIONS_SYNC_CLIENT_ACK));
+        }
+        else
+        {
+            String legacyProperty = System.getProperty("qpid.sync_after_client.ack");
+            if (legacyProperty != null)
+            {
+                _logger.warn("'qpid.sync_after_client.ack' is a deprecated system property, " +
+                             "please use '{}' instead", ClientProperties.SYNC_CLIENT_ACK);
+            }
+            _syncClientAck = Boolean.parseBoolean(System.getProperty(ClientProperties.SYNC_CLIENT_ACK,
+                                                                     legacyProperty != null ? legacyProperty : "true"));
+        }
+
         if (connectionURL.getOption(ConnectionURL.OPTIONS_SYNC_PUBLISH) != null)
         {
             _syncPublish = connectionURL.getOption(ConnectionURL.OPTIONS_SYNC_PUBLISH);
@@ -1761,6 +1780,11 @@ public class AMQConnection extends Close
         return _syncAck;
     }
 
+    boolean getSyncClientAck()
+    {
+        return _syncClientAck;
+    }
+
     public String getSyncPublish()
     {
         return _syncPublish;

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java?rev=1747212&r1=1747211&r2=1747212&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java Tue Jun  7 12:54:58 2016
@@ -1273,7 +1273,10 @@ public class AMQSession_0_10 extends AMQ
         if(ranges.size() > 0 )
         {
             messageAcknowledge(ranges, true);
-            getQpidSession().sync();
+            if (getAMQConnection().getSyncClientAck())
+            {
+                getQpidSession().sync();
+            }
         }
     }
 

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java?rev=1747212&r1=1747211&r2=1747212&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java Tue Jun  7 12:54:58 2016
@@ -73,11 +73,6 @@ public class AMQSession_0_8 extends AMQS
     /** Used for debugging. */
     private static final Logger _logger = LoggerFactory.getLogger(AMQSession.class);
 
-    public static final String QPID_SYNC_AFTER_CLIENT_ACK = "qpid.sync_after_client.ack";
-
-    private final boolean _syncAfterClientAck =
-            Boolean.parseBoolean(System.getProperty(QPID_SYNC_AFTER_CLIENT_ACK, "true"));
-
     private final boolean _useLegacyQueueDepthBehaviour =
             Boolean.parseBoolean(System.getProperty(ClientProperties.QPID_USE_LEGACY_GETQUEUEDEPTH_BEHAVIOUR, "false"));
 
@@ -152,7 +147,7 @@ public class AMQSession_0_8 extends AMQS
         _currentPrefetch.set(0);
         try
         {
-            if (syncRequired && _syncAfterClientAck)
+            if (syncRequired && getAMQConnection().getSyncClientAck())
             {
                 sync();
             }

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java?rev=1747212&r1=1747211&r2=1747212&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java Tue Jun  7 12:54:58 2016
@@ -36,6 +36,7 @@ public interface ConnectionURL
     String OPTIONS_SYNC_PERSISTENCE = "sync_persistence";
     String OPTIONS_MAXPREFETCH = "maxprefetch";
     String OPTIONS_SYNC_ACK = "sync_ack";
+    String OPTIONS_SYNC_CLIENT_ACK = "sync_client_ack";
     String OPTIONS_SYNC_PUBLISH = "sync_publish";
     String OPTIONS_USE_LEGACY_MAP_MESSAGE_FORMAT = "use_legacy_map_msg_format";
     String OPTIONS_USE_LEGACY_STREAM_MESSAGE_FORMAT = "use_legacy_stream_msg_format";

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java?rev=1747212&r1=1747211&r2=1747212&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java Tue Jun  7 12:54:58 2016
@@ -68,6 +68,12 @@ public class ClientProperties
     public static final String SYNC_ACK_PROP_NAME = "sync_ack";
 
     /**
+     * When true a sync command is sent after sending a message ack on a CLIENT_ACK session.
+     * type: boolean
+     */
+    public static final String SYNC_CLIENT_ACK = "sync_client_ack";
+
+    /**
      * sync_publish property - {persistent|all}
      * If set to 'persistent',then persistent messages will be publish synchronously
      * If set to 'all', then all messages regardless of the delivery mode will be

Modified: qpid/java/trunk/doc/jms-client-0-10/src/docbkx/JMS-Client-0-10-Book.xml
URL: http://svn.apache.org/viewvc/qpid/java/trunk/doc/jms-client-0-10/src/docbkx/JMS-Client-0-10-Book.xml?rev=1747212&r1=1747211&r2=1747212&view=diff
==============================================================================
--- qpid/java/trunk/doc/jms-client-0-10/src/docbkx/JMS-Client-0-10-Book.xml (original)
+++ qpid/java/trunk/doc/jms-client-0-10/src/docbkx/JMS-Client-0-10-Book.xml Tue Jun  7 12:54:58 2016
@@ -387,6 +387,36 @@ destination.topicExchange = amq.topic</p
 		  A sync command is sent after every acknowledgement to guarantee that it has been received.
 	        </entry>
 	      </row>
+		  <row>
+			<entry>sync_client_ack</entry>
+			<entry>Boolean</entry>
+			<entry>
+				<para>
+					If set <literal>true</literal>, for sessions using<link
+						xmlns:xlink="http://www.w3.org/1999/xlink"
+						xlink:href="${oracleJeeDocUrl}javax/jms/Session.html#CLIENT_ACKNOWLEDGE">
+					Session#CLIENT_ACKNOWLEDGE</link>,
+					a sync command is sent after every message <link xmlns:xlink="http://www.w3.org/1999/xlink"
+																	xlink:href="${oracleJeeDocUrl}javax/jms/Message.html#acknowledge()">
+					Message#acknowledge()</link>.
+					This ensure that the client awaits the successful processing of the acknowledgement by server
+					before continuing.
+				</para>
+				<para>If <literal>false</literal>, the sync is not performed. This will improve performance but will
+					mean
+					duplicate messages are more likely to be received following a failure.
+				</para>
+				<para>
+					Defaults to<literal>true</literal>.
+				</para>
+				<para>
+					Note: You can also set the default on a client-wide basis by configuring the
+					client using
+					<link linkend="JMS-Client-0-10-Configuring-JVM-Properties">Java system properties.</link>
+				</para>
+			</entry>
+		  </row>
+
 	      <row>
 	        <entry>
 		  use_legacy_map_msg_format
@@ -829,7 +859,26 @@ amqp://guest:guest@/test?failover='round
 		<entry>false</entry>
 		<entry><para>If set, each message will be acknowledged synchronously. When using AUTO_ACK mode, you need to set this to "true", in order to get the correct behaviour as described by the JMS spec.</para><para>This is set to false by default for performance reasons, therefore by default AUTO_ACK behaves similar to DUPS_OK.</para><para>This can also be set per connection using the <link linkend="JMS-Client-0-10-Configuring-JNDI-Connection-URL">Connection URL</link> options.</para></entry>
 	      </row>
-	    </tbody>
+	  	  <row>
+			<entry>sync_client_ack</entry>
+			<entry>boolean</entry>
+			<entry>true</entry>
+			<entry>
+				<para>
+					If set <literal>true</literal>, for sessions using <link xmlns:xlink="http://www.w3.org/1999/xlink"
+					xlink:href="${oracleJeeDocUrl}javax/jms/Session.html#CLIENT_ACKNOWLEDGE">Session#CLIENT_ACKNOWLEDGE</link>,
+					a sync command is sent after every message <link xmlns:xlink="http://www.w3.org/1999/xlink"
+					xlink:href="${oracleJeeDocUrl}javax/jms/Message.html#acknowledge()">Message#acknowledge()</link>.
+					This ensure that the client awaits the successful processing of the acknowledgement by server before continuing.
+				</para>
+				<para>If <literal>false</literal>, the sync is not performed.  This will improve performance but will mean
+					duplicate messages are more likely to be received following a failure.
+				</para>
+				<para>This can also be set per connection using the <link linkend="JMS-Client-0-10-Configuring-JNDI-Connection-URL">
+					Connection URL</link> options.</para>
+			</entry>
+		  </row>
+		</tbody>
 	  </tgroup>
 	</table>
 

Modified: qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml
URL: http://svn.apache.org/viewvc/qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml?rev=1747212&r1=1747211&r2=1747212&view=diff
==============================================================================
--- qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml (original)
+++ qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml Tue Jun  7 12:54:58 2016
@@ -80,12 +80,37 @@
 					  </para>
 					</entry>
 				</row>
+				<!-- 0-10 only
 				<row>
 					<entry> sync_ack </entry>
 					<entry> Boolean </entry>
 					<entry> A sync command is sent after every acknowledgement to guarantee that it
 						has been received. </entry>
 				</row>
+				-->
+				<row>
+					<entry> sync_client_ack </entry>
+					<entry> Boolean </entry>
+					<entry>
+						<para>
+							If set <literal>true</literal>, for sessions using <link xmlns:xlink="http://www.w3.org/1999/xlink"
+							xlink:href="${oracleJeeDocUrl}javax/jms/Session.html#CLIENT_ACKNOWLEDGE">Session#CLIENT_ACKNOWLEDGE</link>,
+							a sync command is sent after every message <link xmlns:xlink="http://www.w3.org/1999/xlink"
+							xlink:href="${oracleJeeDocUrl}javax/jms/Message.html#acknowledge()">Message#acknowledge()</link>.
+							This ensure that the client awaits the successful processing of the acknowledgement by server before continuing.
+						</para>
+						<para>If <literal>false</literal>, the sync is not performed.  This will improve performance but will mean
+							duplicate messages are more likely to be received following a failure.
+						</para>
+						<para>
+							Defaults to <literal>true</literal>.
+						</para>
+						<para>
+							Note: You can also set the default on a client-wide basis by configuring the
+							client using <link linkend="JMS-Client-0-8-System-Properties">Java system properties.</link>
+						</para>
+					</entry>
+				</row>
 				<row xml:id="JMS-Client-0-8-Connection-URL-ConnectionOptions-UseLegacyMap">
 					<entry> use_legacy_map_msg_format </entry>
 					<entry> Boolean </entry>

Modified: qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-System-Properties.xml
URL: http://svn.apache.org/viewvc/qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-System-Properties.xml?rev=1747212&r1=1747211&r2=1747212&view=diff
==============================================================================
--- qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-System-Properties.xml (original)
+++ qpid/java/trunk/doc/jms-client-0-8/src/docbkx/JMS-Client-System-Properties.xml Tue Jun  7 12:54:58 2016
@@ -240,6 +240,25 @@
 								>Connection URL</link> options.</para></entry>
 				</row>
 				-->
+				<row>
+					<entry>sync_client_ack</entry>
+					<entry>boolean</entry>
+					<entry>true</entry>
+					<entry>
+						<para>
+							If set <literal>true</literal>, for sessions using <link xmlns:xlink="http://www.w3.org/1999/xlink"
+							xlink:href="${oracleJeeDocUrl}javax/jms/Session.html#CLIENT_ACKNOWLEDGE">Session#CLIENT_ACKNOWLEDGE</link>,
+							a sync command is sent after every message <link xmlns:xlink="http://www.w3.org/1999/xlink"
+							xlink:href="${oracleJeeDocUrl}javax/jms/Message.html#acknowledge()">Message#acknowledge()</link>.
+							This ensure that the client awaits the successful processing of the acknowledgement by server before continuing.
+						</para>
+						<para>If <literal>false</literal>, the sync is not performed.  This will improve performance but will mean
+							duplicate messages are more likely to be received following a failure.
+						</para>
+						<para>This can also be set per connection using the <link linkend="section-jms-connection-url">
+							Connection URL</link> options.</para>
+					</entry>
+				</row>
 			</tbody>
 		</tgroup>
 	</table>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org