activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r508804 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: activemq/connector/ activemq/connector/openwire/ activemq/connector/stomp/ activemq/core/ cms/
Date Sat, 17 Feb 2007 20:31:21 GMT
Author: nmittler
Date: Sat Feb 17 12:31:21 2007
New Revision: 508804

URL: http://svn.apache.org/viewvc?view=rev&rev=508804
Log:
[AMQCPP-30] adding support for unsubscribing a durable destination

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/Connector.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Session.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/Connector.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/Connector.h?view=diff&rev=508804&r1=508803&r2=508804
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/Connector.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/Connector.h Sat Feb
17 12:31:21 2007
@@ -33,6 +33,7 @@
 #include <cms/MapMessage.h>
 
 #include <activemq/exceptions/InvalidStateException.h>
+#include <activemq/exceptions/UnsupportedOperationException.h>
 
 #include <activemq/transport/Transport.h>
 #include <activemq/connector/SessionInfo.h>
@@ -63,28 +64,28 @@
 
     public:
 
-           virtual ~Connector(void) {};
+        virtual ~Connector() {};
 
         /**
          * Gets the Client Id for this connection, if this
          * connection has been closed, then this method returns ""
          * @return Client Id String
          */
-        virtual std::string getClientId(void) const = 0;
+        virtual std::string getClientId() const = 0;
 
         /**
          * Gets the Username for this connection, if this
          * connection has been closed, then this method returns ""
          * @return Username String
          */
-        virtual std::string getUsername(void) const = 0;
+        virtual std::string getUsername() const = 0;
 
         /**
          * Gets the Password for this connection, if this
          * connection has been closed, then this method returns ""
          * @return Password String
          */
-        virtual std::string getPassword(void) const = 0;
+        virtual std::string getPassword() const = 0;
 
         /**
          * Gets a reference to the Transport that this connection
@@ -92,7 +93,7 @@
          * @return reference to a transport
          * @throws InvalidStateException if the Transport is not set
          */
-        virtual transport::Transport& getTransport(void) const
+        virtual transport::Transport& getTransport() const
             throw (exceptions::InvalidStateException ) = 0;
 
         /**
@@ -179,20 +180,22 @@
          * @param session Session Information
          * @return a newly created Temporary Topic Object
          * @throws ConnectorException
+         * @throws UnsupportedOperationException
          */
         virtual cms::TemporaryTopic* createTemporaryTopic(
             SessionInfo* session )
-                throw ( ConnectorException ) = 0;
+                throw ( ConnectorException, exceptions::UnsupportedOperationException ) =
0;
 
         /**
          * Creates a Temporary Queue given a name and session info
          * @param session Session Information
          * @return a newly created Temporary Queue Object
          * @throws ConnectorException
+         * @throws UnsupportedOperationException
          */
         virtual cms::TemporaryQueue* createTemporaryQueue(
             SessionInfo* session )
-                throw ( ConnectorException ) = 0;
+                throw ( ConnectorException, exceptions::UnsupportedOperationException ) =
0;
 
         /**
          * Sends a Message
@@ -294,19 +297,21 @@
          * @param session Session Information
          * @param transaction Transaction Info for this Message
          * @throws ConnectorException
+         * @throws UnsupportedOperationException
          */
         virtual cms::MapMessage* createMapMessage(
             SessionInfo* session,
             TransactionInfo* transaction )
-                throw ( ConnectorException ) = 0;
+                throw ( ConnectorException, exceptions::UnsupportedOperationException ) =
0;
 
         /**
          * Unsubscribe from a givenDurable Subscription
          * @param name name of the Subscription
          * @throws ConnectorException
+         * @throws UnsupportedOperationException
          */
         virtual void unsubscribe( const std::string&  )
-            throw ( ConnectorException ) = 0;
+            throw ( ConnectorException, exceptions::UnsupportedOperationException ) = 0;
 
         /**
          * Destroys the given connector resource.

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=508804&r1=508803&r2=508804
==============================================================================
--- 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 12:31:21 2007
@@ -54,6 +54,7 @@
 #include <activemq/connector/openwire/commands/TransactionInfo.h>
 #include <activemq/connector/openwire/commands/LocalTransactionId.h>
 #include <activemq/connector/openwire/commands/WireFormatInfo.h>
+#include <activemq/connector/openwire/commands/RemoveSubscriptionInfo.h>
 
 using namespace std;
 using namespace activemq;
@@ -633,7 +634,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 cms::TemporaryTopic* OpenWireConnector::createTemporaryTopic(
     connector::SessionInfo* session AMQCPP_UNUSED )
-        throw ( ConnectorException )
+        throw ( ConnectorException, UnsupportedOperationException )
 {
     try
     {
@@ -654,7 +655,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 cms::TemporaryQueue* OpenWireConnector::createTemporaryQueue(
     connector::SessionInfo* session AMQCPP_UNUSED )
-        throw ( ConnectorException )
+        throw ( ConnectorException, UnsupportedOperationException )
 {
     try
     {
@@ -983,7 +984,7 @@
 cms::MapMessage* OpenWireConnector::createMapMessage(
     connector::SessionInfo* session AMQCPP_UNUSED,
     TransactionInfo* transaction AMQCPP_UNUSED )
-        throw ( ConnectorException )
+        throw ( ConnectorException, UnsupportedOperationException )
 {
     try
     {
@@ -995,16 +996,38 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 void OpenWireConnector::unsubscribe( const std::string& name )
-    throw ( ConnectorException )
+    throw ( ConnectorException, UnsupportedOperationException )
 {
+    commands::RemoveSubscriptionInfo* rsi = NULL;
+    
     try
     {
         enforceConnected();
+        
+        rsi = new commands::RemoveSubscriptionInfo();
+        rsi->setConnectionId( dynamic_cast<commands::ConnectionId*>(
+            connectionInfo.getConnectionId()->cloneDataStructure()) );
+        rsi->setSubcriptionName(name);
+        rsi->setClientId(connectionInfo.getClientId());
+                
+        // Send the message to the broker.
+        Response* response = syncRequest(rsi);
 
-        // TODO
+        // The broker did not return an error - this is good.
+        // Just discard the response.
+        delete response;
+        
+    } catch( ConnectorException& ex ) {
+        delete rsi;
+
+        ex.setMark( __FILE__, __LINE__ );
+        throw ex;
+    } catch( ... ) {
+        delete rsi;
+
+        throw OpenWireConnectorException( __FILE__, __LINE__,
+            "caught unknown exception" );
     }
-    AMQ_CATCH_RETHROW( ConnectorException )
-    AMQ_CATCHALL_THROW( OpenWireConnectorException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.h?view=diff&rev=508804&r1=508803&r2=508804
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.h
Sat Feb 17 12:31:21 2007
@@ -239,20 +239,20 @@
          * Starts the service.
          * @throws CMSException
          */
-        virtual void start(void) throw( cms::CMSException );
+        virtual void start() throw( cms::CMSException );
 
         /**
          * Closes this object and deallocates the appropriate resources.
          * @throws CMSException
          */
-        virtual void close(void) throw( cms::CMSException );
+        virtual void close() throw( cms::CMSException );
 
         /**
          * Gets the Client Id for this connection, if this
          * connection has been closed, then this method returns ""
          * @return Client Id String
          */
-        virtual std::string getClientId(void) const {
+        virtual std::string getClientId() const {
             return properties.getProperty(
                 core::ActiveMQConstants::toString(
                     core::ActiveMQConstants::PARAM_CLIENTID ), "" );
@@ -263,7 +263,7 @@
          * connection has been closed, then this method returns ""
          * @return Username String
          */
-        virtual std::string getUsername(void) const {
+        virtual std::string getUsername() const {
             return properties.getProperty(
                 core::ActiveMQConstants::toString(
                     core::ActiveMQConstants::PARAM_USERNAME ), "" );
@@ -274,7 +274,7 @@
          * connection has been closed, then this method returns ""
          * @return Password String
          */
-        virtual std::string getPassword(void) const {
+        virtual std::string getPassword() const {
             return properties.getProperty(
                 core::ActiveMQConstants::toString(
                     core::ActiveMQConstants::PARAM_PASSWORD ), "" );
@@ -286,7 +286,7 @@
          * @param reference to a transport
          * @throws InvalidStateException if the Transport is not set
          */
-        virtual transport::Transport& getTransport(void) const
+        virtual transport::Transport& getTransport() const
             throw ( exceptions::InvalidStateException ) {
 
             if( transport == NULL ) {
@@ -387,7 +387,7 @@
          */
         virtual cms::TemporaryTopic* createTemporaryTopic(
             SessionInfo* session )
-                throw ( ConnectorException );
+                throw ( ConnectorException, exceptions::UnsupportedOperationException );
 
         /**
          * Creates a Temporary Queue given a name and session info
@@ -398,7 +398,7 @@
          */
         virtual cms::TemporaryQueue* createTemporaryQueue(
             SessionInfo* session )
-                throw ( ConnectorException );
+                throw ( ConnectorException, exceptions::UnsupportedOperationException );
 
         /**
          * Sends a Message
@@ -504,7 +504,7 @@
         virtual cms::MapMessage* createMapMessage(
             SessionInfo* session,
             TransactionInfo* transaction )
-                throw ( ConnectorException );
+                throw ( ConnectorException, exceptions::UnsupportedOperationException );
 
         /**
          * Unsubscribe from a givenDurable Subscription
@@ -512,7 +512,7 @@
          * @throws ConnectorException
          */
         virtual void unsubscribe( const std::string& name )
-            throw ( ConnectorException );
+            throw ( ConnectorException, exceptions::UnsupportedOperationException );
 
         /**
          * Destroys the given connector resource.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp?view=diff&rev=508804&r1=508803&r2=508804
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
Sat Feb 17 12:31:21 2007
@@ -31,7 +31,6 @@
 #include <activemq/connector/stomp/commands/TextMessageCommand.h>
 #include <activemq/connector/stomp/commands/ConnectedCommand.h>
 #include <activemq/connector/stomp/commands/DisconnectCommand.h>
-#include <activemq/exceptions/UnsupportedOperationException.h>
 #include <activemq/connector/stomp/StompProducerInfo.h>
 #include <activemq/connector/stomp/StompTransactionInfo.h>
 #include <activemq/util/Integer.h>
@@ -387,7 +386,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 cms::TemporaryTopic* StompConnector::createTemporaryTopic(
     SessionInfo* session AMQCPP_UNUSED)
-        throw ( ConnectorException )
+        throw ( ConnectorException, UnsupportedOperationException )
 {
     try
     {
@@ -403,7 +402,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 cms::TemporaryQueue* StompConnector::createTemporaryQueue(
     SessionInfo* session AMQCPP_UNUSED)
-        throw ( ConnectorException )
+        throw ( ConnectorException, UnsupportedOperationException )
 {
     try
     {
@@ -693,7 +692,7 @@
 cms::MapMessage* StompConnector::createMapMessage(
     SessionInfo* session AMQCPP_UNUSED,
     TransactionInfo* transaction AMQCPP_UNUSED )
-        throw ( ConnectorException )
+        throw ( ConnectorException, UnsupportedOperationException )
 {
     try
     {
@@ -708,7 +707,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 void StompConnector::unsubscribe( const std::string& name AMQCPP_UNUSED )
-    throw ( ConnectorException )
+    throw ( ConnectorException, UnsupportedOperationException )
 {
     try
     {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h?view=diff&rev=508804&r1=508803&r2=508804
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h
Sat Feb 17 12:31:21 2007
@@ -332,7 +332,7 @@
          */
         virtual cms::TemporaryTopic* createTemporaryTopic(
             SessionInfo* session )
-                throw ( ConnectorException );
+                throw ( ConnectorException, exceptions::UnsupportedOperationException );
 
         /**
          * Creates a Temporary Queue given a name and session info
@@ -342,7 +342,7 @@
          */
         virtual cms::TemporaryQueue* createTemporaryQueue(
             SessionInfo* session )
-                throw ( ConnectorException );
+                throw ( ConnectorException, exceptions::UnsupportedOperationException );
 
         /**
          * Sends a Message
@@ -448,7 +448,7 @@
         virtual cms::MapMessage* createMapMessage(
             SessionInfo* session,
             TransactionInfo* transaction )
-                throw ( ConnectorException );
+                throw ( ConnectorException, exceptions::UnsupportedOperationException );
 
         /**
          * Unsubscribe from a givenDurable Subscription
@@ -456,7 +456,7 @@
          * @throws ConnectorException
          */
         virtual void unsubscribe( const std::string& name )
-            throw ( ConnectorException );
+            throw ( ConnectorException, exceptions::UnsupportedOperationException );
 
         /**
          * Destroys the given connector resource.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp?view=diff&rev=508804&r1=508803&r2=508804
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.cpp Sat
Feb 17 12:31:21 2007
@@ -799,3 +799,24 @@
     AMQ_CATCH_RETHROW( ActiveMQException )
     AMQ_CATCHALL_THROW( ActiveMQException )
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQSession::unsubscribe( const std::string& name ) 
+    throw ( CMSException )
+{
+    try
+    {
+        if( closed )
+        {
+            throw InvalidStateException(
+                __FILE__, __LINE__,
+                "ActiveMQSession::createConsumer - Session Already Closed" );
+        }
+
+        // Delegate to the connector.
+        connection->getConnectionData()->getConnector()->unsubscribe( name );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h?view=diff&rev=508804&r1=508803&r2=508804
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h Sat
Feb 17 12:31:21 2007
@@ -266,6 +266,22 @@
          * @return transacted true - false.
          */
         virtual bool isTransacted() const;
+        
+        /**
+         * Unsubscribes a durable subscription that has been created by a 
+         * client.
+         * 
+         * This method deletes the state being maintained on behalf of the 
+         * subscriber by its provider.  It is erroneous for a client to delete a 
+         * durable subscription while there is an active MessageConsumer or 
+         * Subscriber for the subscription, or while a consumed message is 
+         * part of a pending transaction or has not been acknowledged in the 
+         * session.
+         * @param name the name used to identify this subscription
+         * @throws CMSException
+         */
+        virtual void unsubscribe( const std::string& name ) 
+            throw ( cms::CMSException );
 
    public:   // ActiveMQSession specific Methods
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Session.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Session.h?view=diff&rev=508804&r1=508803&r2=508804
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Session.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Session.h Sat Feb 17 12:31:21 2007
@@ -258,6 +258,22 @@
          * @return transacted true - false.
          */
         virtual bool isTransacted() const = 0;
+        
+        /**
+         * Unsubscribes a durable subscription that has been created by a 
+         * client.
+         * 
+         * This method deletes the state being maintained on behalf of the 
+         * subscriber by its provider.  It is erroneous for a client to delete a 
+         * durable subscription while there is an active MessageConsumer or 
+         * Subscriber for the subscription, or while a consumed message is 
+         * part of a pending transaction or has not been acknowledged in the 
+         * session.
+         * @param name the name used to identify this subscription
+         * @throws CMSException
+         */
+        virtual void unsubscribe( const std::string& name ) 
+            throw ( CMSException ) = 0;
 
     };
 



Mime
View raw message