Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 95209 invoked from network); 17 Feb 2007 17:54:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Feb 2007 17:54:41 -0000 Received: (qmail 37659 invoked by uid 500); 17 Feb 2007 17:54:49 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 37631 invoked by uid 500); 17 Feb 2007 17:54:49 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 37622 invoked by uid 99); 17 Feb 2007 17:54:49 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Feb 2007 09:54:49 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Feb 2007 09:54:40 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 5A0A01A981A; Sat, 17 Feb 2007 09:54:20 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r508784 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp Date: Sat, 17 Feb 2007 17:54:20 -0000 To: commits@activemq.apache.org From: nmittler@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070217175420.5A0A01A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nmittler Date: Sat Feb 17 09:54:19 2007 New Revision: 508784 URL: http://svn.apache.org/viewvc?view=rev&rev=508784 Log: [AMQCPP-30] adding support for creating producers in openwire Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp?view=diff&rev=508784&r1=508783&r2=508784 ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp Sat Feb 17 09:54:19 2007 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -419,42 +420,70 @@ connector::SessionInfo* session ) throw ( ConnectorException ) { + OpenWireProducerInfo* producer = NULL; + commands::ProducerInfo* producerInfo = NULL; + try { enforceConnected(); - OpenWireProducerInfo* producer = new OpenWireProducerInfo(); - - commands::ProducerInfo* producerInfo = new commands::ProducerInfo(); + producer = new OpenWireProducerInfo(); + producerInfo = new commands::ProducerInfo(); + producer->setProducerInfo( producerInfo ); + commands::ProducerId* producerId = new commands::ProducerId(); + producerInfo->setProducerId( producerId ); producerId->setConnectionId( session->getConnectionId() ); producerId->setSessionId( session->getSessionId() ); producerId->setValue( getNextProducerId() ); - producerInfo->setProducerId( producerId ); - -// TODO -// answer.Destination = ActiveMQDestination.Transform(destination); -// -// answer.Destination = ActiveMQDestination.Transform(destination); -// -// // If the destination contained a URI query, then use it to set public -// // properties on the ProducerInfo -// ActiveMQDestination amqDestination = destination as ActiveMQDestination; -// if (amqDestination != null && amqDestination.Options != null) -// { -// Util.URISupport.SetProperties(answer, amqDestination.Options, "producer."); -// } -// -// return answer; - - producer->setProducerInfo( producerInfo ); + // Cast the destination to an OpenWire destination, so we can + // get all the goodies. + const commands::ActiveMQDestination* amqDestination = + dynamic_cast(destination); + if( amqDestination == NULL ) { + throw ConnectorException( __FILE__, __LINE__, + "Destination was either NULL or not created by this OpenWireConnector" ); + } + + // Get any options specified in the destination and apply them to the + // ProducerInfo object. + producerInfo->setDestination( dynamic_cast( + amqDestination->cloneDataStructure()) ); + const Properties& options = amqDestination->getOptions(); + producerInfo->setDispatchAsync( Boolean::parseBoolean( + options.getProperty( "producer.dispatchAsync", "false" )) ); + + // Send the message to the broker. + Response* response = syncRequest(producerInfo); + + // The broker did not return an error - this is good. + // Just discard the response. + delete response; return producer; + + } catch( ConnectorException& ex ) { + delete producer; + delete producerInfo; + + ex.setMark( __FILE__, __LINE__ ); + throw ex; + } catch( std::exception& ex ) { + delete producer; + delete producerInfo; + + throw OpenWireConnectorException( __FILE__, __LINE__, + ex.what() ); + + } catch( ... ) { + delete producer; + delete producerInfo; + + throw OpenWireConnectorException( __FILE__, __LINE__, + "caught unknown exception" ); } - AMQ_CATCH_RETHROW( ConnectorException ) - AMQ_CATCHALL_THROW( OpenWireConnectorException ) } //////////////////////////////////////////////////////////////////////////////// @@ -831,6 +860,8 @@ OpenWireConsumerInfo* consumer = dynamic_cast(resource); + OpenWireProducerInfo* producer = + dynamic_cast(resource); OpenWireSessionInfo* session = dynamic_cast(resource); commands::ActiveMQTempDestination* tempDestination = @@ -838,6 +869,8 @@ if( consumer != NULL ) { dataStructure = consumer->getConsumerInfo(); + } else if( producer != NULL ) { + dataStructure = producer->getProducerInfo(); } else if( session != NULL ) { dataStructure = session->getSessionInfo(); } else if( tempDestination != NULL ) { @@ -1016,7 +1049,12 @@ dynamic_cast( tempDestination->cloneDataStructure() ) ); - this->syncRequest( &command ); + // Send the message to the broker. + Response* response = syncRequest(&command); + + // The broker did not return an error - this is good. + // Just discard the response. + delete response; } AMQ_CATCH_RETHROW( ConnectorException ) AMQ_CATCHALL_THROW( OpenWireConnectorException ) @@ -1037,7 +1075,12 @@ dynamic_cast( tempDestination->cloneDataStructure() ) ); - this->syncRequest( &command ); + // Send the message to the broker. + Response* response = syncRequest(&command); + + // The broker did not return an error - this is good. + // Just discard the response. + delete response; } AMQ_CATCH_RETHROW( ConnectorException ) AMQ_CATCHALL_THROW( OpenWireConnectorException )