You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2016/04/11 19:44:47 UTC

svn commit: r1738613 - in /qpid/java/branches/6.0.x: ./ client/src/main/java/org/apache/qpid/client/ client/src/main/java/org/apache/qpid/jms/ client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ doc/jms-client-0-8/src/docbkx/ systests/...

Author: orudyy
Date: Mon Apr 11 17:44:47 2016
New Revision: 1738613

URL: http://svn.apache.org/viewvc?rev=1738613&view=rev
Log:
QPID-7159: Add connection parameter to control whether a MessageProducer will populate the JMSXUserID value for each sent message using the authenticated username from the connection

          Merged from trunk
          svn merge -c 1737853,1738610  ^/qpid/java/trunk

Added:
    qpid/java/branches/6.0.x/systests/src/test/java/org/apache/qpid/test/client/message/JMSXUserIDTest.java
      - copied unchanged from r1738610, qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/client/message/JMSXUserIDTest.java
Modified:
    qpid/java/branches/6.0.x/   (props changed)
    qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/AMQConnection.java
    qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
    qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java
    qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
    qpid/java/branches/6.0.x/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
    qpid/java/branches/6.0.x/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml

Propchange: qpid/java/branches/6.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Apr 11 17:44:47 2016
@@ -9,5 +9,5 @@
 /qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720340,1720664,1721151,1721198,1722019-1722020,1722246,1722339,1722416,1722674,1722678,1722683,1722711,1723064,1723194,1723563,1724216,1724251,1724257,1724292,1724375,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1725760,1726176,1726244-1726246,1726249,1726358,1726436,1726449,1726456,1726646,1726653,1726755,1726778,1727532,1727555,1727608,1727951,1727954,1728089,1728167,1728302,1728497,1728501,1728524,1728639,1728651,1728772,1729215,1729297,1729347,1729356,1729406,1729408,1729412,1729515,1729638,1729656-1729
 657,1729783,1729828,1729832,1729841,1729851,1729886,1729904,1729973,1730019,1730025,1730052,1730072,1730088,1730494,1730499,1730547,1730559,1730567,1730578,1730585,1730651,1730697,1730712-1730713,1730805,1731029,1731110,1731210,1731225,1731444,1731551,1731612,1732184,1732452,1732461,1732525,1732812,1734452,1736478,1736751,1736838,1737588,1737804,1737835,1737984,1737992,1738119,1738231
+/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720340,1720664,1721151,1721198,1722019-1722020,1722246,1722339,1722416,1722674,1722678,1722683,1722711,1723064,1723194,1723563,1724216,1724251,1724257,1724292,1724375,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1725760,1726176,1726244-1726246,1726249,1726358,1726436,1726449,1726456,1726646,1726653,1726755,1726778,1727532,1727555,1727608,1727951,1727954,1728089,1728167,1728302,1728497,1728501,1728524,1728639,1728651,1728772,1729215,1729297,1729347,1729356,1729406,1729408,1729412,1729515,1729638,1729656-1729
 657,1729783,1729828,1729832,1729841,1729851,1729886,1729904,1729973,1730019,1730025,1730052,1730072,1730088,1730494,1730499,1730547,1730559,1730567,1730578,1730585,1730651,1730697,1730712-1730713,1730805,1731029,1731110,1731210,1731225,1731444,1731551,1731612,1732184,1732452,1732461,1732525,1732812,1734452,1736478,1736751,1736838,1737804,1737835,1737853,1737984,1737992,1738119,1738231,1738610
 /qpid/trunk/qpid:796646-796653

Modified: qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/AMQConnection.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/AMQConnection.java?rev=1738613&r1=1738612&r2=1738613&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/AMQConnection.java (original)
+++ qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/AMQConnection.java Mon Apr 11 17:44:47 2016
@@ -207,6 +207,10 @@ public class AMQConnection extends Close
     //By default it's async publish
     private String _syncPublish = "";
 
+    //Indicates whether user-id should be attached to every sent message
+    //By default the user ID is attached
+    private boolean _populateUserId = true;
+
     // Indicates whether to use the old map message format or the
     // new amqp-0-10 encoded format.
     private boolean _useLegacyMapMessageFormat;
@@ -347,6 +351,11 @@ public class AMQConnection extends Close
             _syncPublish = System.getProperty((ClientProperties.SYNC_PUBLISH_PROP_NAME),_syncPublish);
         }
 
+        if (connectionURL.getOption(ConnectionURL.OPTIONS_POPULATE_USER_ID) != null)
+        {
+            _populateUserId = Boolean.parseBoolean(connectionURL.getOption(ConnectionURL.OPTIONS_POPULATE_USER_ID));
+        }
+
         if (connectionURL.getOption(ConnectionURL.OPTIONS_USE_LEGACY_MAP_MESSAGE_FORMAT) != null)
         {
             _useLegacyMapMessageFormat =  Boolean.parseBoolean(
@@ -1750,6 +1759,11 @@ public class AMQConnection extends Close
         return _syncPublish;
     }
 
+    public boolean isPopulateUserId()
+    {
+        return _populateUserId;
+    }
+
     public boolean isMessageCompressionDesired()
     {
         return _compressMessages;

Modified: qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java?rev=1738613&r1=1738612&r2=1738613&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java (original)
+++ qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java Mon Apr 11 17:44:47 2016
@@ -149,7 +149,7 @@ public abstract class BasicMessageProduc
                                             : _defaultMandatoryValue
                 : mandatory;
 
-        _userID = connection.getUsername();
+        _userID = connection.isPopulateUserId() ? connection.getUsername() : null;
         setPublishMode();
     }
 

Modified: qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java?rev=1738613&r1=1738612&r2=1738613&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java (original)
+++ qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java Mon Apr 11 17:44:47 2016
@@ -121,7 +121,10 @@ public class BasicMessageProducer_0_10 e
         MessageProperties messageProps = delegate.getMessageProperties();
 
         // On the receiving side, this will be read in to the JMSXUserID as well.
-        messageProps.setUserId(userIDBytes);
+        if (getConnection().isPopulateUserId())
+        {
+            messageProps.setUserId(userIDBytes);
+        }
                 
         if (messageId != null)
         {

Modified: qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java?rev=1738613&r1=1738612&r2=1738613&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java (original)
+++ qpid/java/branches/6.0.x/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java Mon Apr 11 17:44:47 2016
@@ -82,6 +82,11 @@ public interface ConnectionURL
     String OPTIONS_TEMPORARY_QUEUE_EXCHANGE = "temporaryQueueExchange";
     String OPTIONS_VERIFY_QUEUE_ON_SEND = "verifyQueueOnSend";
 
+    /**
+     * This option specifies whether User-ID should be attached to each message sent over the connection
+     */
+    String OPTIONS_POPULATE_USER_ID = "populateJMSXUserID";
+
     byte  URL_0_8 = 1;
     byte  URL_0_10 = 2;
 

Modified: qpid/java/branches/6.0.x/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java?rev=1738613&r1=1738612&r2=1738613&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java (original)
+++ qpid/java/branches/6.0.x/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java Mon Apr 11 17:44:47 2016
@@ -648,5 +648,12 @@ public class ConnectionURLTest extends Q
         assertEquals(connectionurl.hashCode(), deserialisedConnectionUrl.hashCode());
 
     }
+
+    public void testPopulateJMSXUserID() throws URLSyntaxException
+    {
+        String url = "amqp://test:test@/test?brokerlist='tcp://localhost:5672'&populateJMSXUserID='false'";
+        ConnectionURL connectionurl = new AMQConnectionURL(url);
+        assertEquals("false", connectionurl.getOption(ConnectionURL.OPTIONS_POPULATE_USER_ID));
+    }
 }
 

Modified: qpid/java/branches/6.0.x/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml?rev=1738613&r1=1738612&r2=1738613&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml (original)
+++ qpid/java/branches/6.0.x/doc/jms-client-0-8/src/docbkx/JMS-Client-Connection-URL.xml Mon Apr 11 17:44:47 2016
@@ -149,6 +149,12 @@
 					<entry>Integer</entry>
 					<entry><para>The payload size beyond which the client will start to compress message payloads.</para></entry>
 				</row>
+				<row xml:id="JMS-Client-0-8-Connection-URL-ConnectionOptions-populateJMSXUserID">
+					<entry>populateJMSXUserID</entry>
+					<entry>boolean</entry>
+					<entry><para>Controls whether a MessageProducer will populate the JMSXUserID value for each sent message using the authenticated username from the connection.
+						It is set to true by default.</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