activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1069566 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: examples/producers/ main/activemq/core/ main/activemq/transport/failover/ test/activemq/util/
Date Thu, 10 Feb 2011 21:06:05 GMT
Author: tabish
Date: Thu Feb 10 21:06:04 2011
New Revision: 1069566

URL: http://svn.apache.org/viewvc?rev=1069566&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQCPP-350

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp?rev=1069566&r1=1069565&r2=1069566&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/producers/SimpleProducer.cpp Thu
Feb 10 21:06:04 2011
@@ -202,13 +202,13 @@ int main(int argc AMQCPP_UNUSED, char* a
     //    tcp://127.0.0.1:61613?wireFormat=stomp     use stomp instead
     //
     std::string brokerURI =
-        "failover:(tcp://127.0.0.1:61616"
+        "failover://(tcp://127.0.0.1:61616"
 //        "?wireFormat=openwire"
 //        "&connection.useAsyncSend=true"
 //        "&transport.commandTracingEnabled=true"
 //        "&transport.tcpTracingEnabled=true"
 //        "&wireFormat.tightEncodingEnabled=true"
-        ")";
+        ")?startupMaxReconnectAttempts=10&initialReconnectDelay=1";
 
     //============================================================
     // Total number of messages for this producer to send.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp?rev=1069566&r1=1069565&r2=1069566&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
Thu Feb 10 21:06:04 2011
@@ -30,6 +30,7 @@
 #include <activemq/core/policies/DefaultPrefetchPolicy.h>
 #include <activemq/core/policies/DefaultRedeliveryPolicy.h>
 #include <activemq/util/URISupport.h>
+#include <activemq/util/CompositeData.h>
 #include <memory>
 
 using namespace std;
@@ -104,7 +105,16 @@ namespace core{
 
             this->brokerURI = uri;
             this->properties->clear();
-            activemq::util::URISupport::parseQuery( uri.getQuery(), properties.get() );
+
+            if( uri.getQuery() != "" ) {
+                // Not a composite URI so this works fine.
+                activemq::util::URISupport::parseQuery( uri.getQuery(), properties.get()
);
+            } else {
+                // Composite URI won't indicate it has a query even if it does.
+                activemq::util::CompositeData composite = activemq::util::URISupport::parseComposite(
uri );
+
+                *this->properties = composite.getParameters();
+            }
 
             // Check the connection options
             this->alwaysSyncSend = Boolean::parseBoolean(

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp?rev=1069566&r1=1069565&r2=1069566&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/FailoverTransportFactory.cpp
Thu Feb 10 21:06:04 2011
@@ -42,8 +42,7 @@ Pointer<Transport> FailoverTransportFact
 
     try{
 
-        Properties properties =
-            activemq::util::URISupport::parseQuery( location.getQuery() );
+        Properties properties;  // unused but necessary for now.
 
         // Create the initial Transport, then wrap it in the normal Filters
         Pointer<Transport> transport( doCreateComposite( location, properties ) );
@@ -63,8 +62,7 @@ Pointer<Transport> FailoverTransportFact
 
     try{
 
-        Properties properties =
-            activemq::util::URISupport::parseQuery( location.getQuery() );
+        Properties properties;  // unused but necessary for now.
 
         // Create the initial Transport, then wrap it in the normal Filters
         return doCreateComposite( location, properties );
@@ -84,28 +82,30 @@ Pointer<Transport> FailoverTransportFact
         CompositeData data = URISupport::parseComposite( location );
         Pointer<FailoverTransport> transport( new FailoverTransport() );
 
+        Properties topLvlProperties = data.getParameters();
+
         transport->setInitialReconnectDelay(
-            Long::parseLong( properties.getProperty( "initialReconnectDelay", "10" ) ) );
+            Long::parseLong( topLvlProperties.getProperty( "initialReconnectDelay", "10"
) ) );
         transport->setMaxReconnectDelay(
-            Long::parseLong( properties.getProperty( "maxReconnectDelay", "30000" ) ) );
+            Long::parseLong( topLvlProperties.getProperty( "maxReconnectDelay", "30000" )
) );
         transport->setUseExponentialBackOff(
-            Boolean::parseBoolean( properties.getProperty( "useExponentialBackOff", "true"
) ) );
+            Boolean::parseBoolean( topLvlProperties.getProperty( "useExponentialBackOff",
"true" ) ) );
         transport->setMaxReconnectAttempts(
-            Integer::parseInt( properties.getProperty( "maxReconnectAttempts", "0" ) ) );
+            Integer::parseInt( topLvlProperties.getProperty( "maxReconnectAttempts", "0"
) ) );
         transport->setStartupMaxReconnectAttempts(
-            Integer::parseInt( properties.getProperty( "startupMaxReconnectAttempts", "0"
) ) );
+            Integer::parseInt( topLvlProperties.getProperty( "startupMaxReconnectAttempts",
"0" ) ) );
         transport->setRandomize(
-            Boolean::parseBoolean( properties.getProperty( "randomize", "true" ) ) );
+            Boolean::parseBoolean( topLvlProperties.getProperty( "randomize", "true" ) )
);
         transport->setBackup(
-            Boolean::parseBoolean( properties.getProperty( "backup", "false" ) ) );
+            Boolean::parseBoolean( topLvlProperties.getProperty( "backup", "false" ) ) );
         transport->setBackupPoolSize(
-            Integer::parseInt( properties.getProperty( "backupPoolSize", "1" ) ) );
+            Integer::parseInt( topLvlProperties.getProperty( "backupPoolSize", "1" ) ) );
         transport->setTimeout(
-            Long::parseLong( properties.getProperty( "timeout", "-1" ) ) );
+            Long::parseLong( topLvlProperties.getProperty( "timeout", "-1" ) ) );
         transport->setTrackMessages(
-            Boolean::parseBoolean( properties.getProperty( "trackMessages", "false" ) ) );
+            Boolean::parseBoolean( topLvlProperties.getProperty( "trackMessages", "false"
) ) );
         transport->setMaxCacheSize(
-            Integer::parseInt( properties.getProperty( "maxCacheSize", "131072" ) ) );
+            Integer::parseInt( topLvlProperties.getProperty( "maxCacheSize", "131072" ) )
);
 
         transport->addURI( false, data.getComponents() );
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp?rev=1069566&r1=1069565&r2=1069566&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp Thu
Feb 10 21:06:04 2011
@@ -65,6 +65,26 @@ void URISupportTest::test() {
     } catch(...) {
         CPPUNIT_ASSERT( false );
     }
+
+    string test5 = "failover:(tcp://127.0.0.1:61616)?startupMaxReconnectAttempts=10&initialReconnectDelay=10";
+
+    map = URISupport::parseQuery( test5 );
+
+    CPPUNIT_ASSERT( map.hasProperty( "startupMaxReconnectAttempts" ) == true );
+    CPPUNIT_ASSERT( map.hasProperty( "initialReconnectDelay" ) == true );
+
+    CPPUNIT_ASSERT( map.getProperty( "startupMaxReconnectAttempts", "" ) == "10" );
+    CPPUNIT_ASSERT( map.getProperty( "initialReconnectDelay", "" ) == "10" );
+
+    string test6 = "failover://(tcp://127.0.0.1:61616)?startupMaxReconnectAttempts=10&initialReconnectDelay=10";
+
+    map = URISupport::parseQuery( test6 );
+
+    CPPUNIT_ASSERT( map.hasProperty( "startupMaxReconnectAttempts" ) == true );
+    CPPUNIT_ASSERT( map.hasProperty( "initialReconnectDelay" ) == true );
+
+    CPPUNIT_ASSERT( map.getProperty( "startupMaxReconnectAttempts", "" ) == "10" );
+    CPPUNIT_ASSERT( map.getProperty( "initialReconnectDelay", "" ) == "10" );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -151,4 +171,26 @@ void URISupportTest::testParseComposite(
     CPPUNIT_ASSERT( data.getComponents().get(0).toString() ==
                     "tcp://localhost:61616?wireformat=openwire" );
 
+    data = URISupport::parseComposite(
+        URI( "broker:(tcp://localhost:61616?wireformat=openwire)?name=foo" ) );
+
+    CPPUNIT_ASSERT( data.getScheme() == "broker" );
+    CPPUNIT_ASSERT( data.getParameters().hasProperty( "name" ) );
+    CPPUNIT_ASSERT( !data.getParameters().hasProperty( "wireformat" ) );
+    CPPUNIT_ASSERT( string( data.getParameters().getProperty( "name" ) ) == "foo" );
+    CPPUNIT_ASSERT( data.getComponents().size() == 1 );
+    CPPUNIT_ASSERT( data.getComponents().get(0).toString() ==
+                    "tcp://localhost:61616?wireformat=openwire" );
+
+    data = URISupport::parseComposite(
+        URI( "broker:(tcp://localhost:61616)?name=foo" ) );
+
+    CPPUNIT_ASSERT( data.getScheme() == "broker" );
+    CPPUNIT_ASSERT( data.getParameters().hasProperty( "name" ) );
+    CPPUNIT_ASSERT( !data.getParameters().hasProperty( "wireformat" ) );
+    CPPUNIT_ASSERT( string( data.getParameters().getProperty( "name" ) ) == "foo" );
+    CPPUNIT_ASSERT( data.getComponents().size() == 1 );
+    CPPUNIT_ASSERT( data.getComponents().get(0).toString() ==
+                    "tcp://localhost:61616" );
+
 }



Mime
View raw message