You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2015/08/04 00:27:44 UTC

[1/2] activemq-cpp git commit: Clean up a bit

Repository: activemq-cpp
Updated Branches:
  refs/heads/master 3e09e6663 -> 54c3b9d29


Clean up a bit

Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/44bb9259
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/44bb9259
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/44bb9259

Branch: refs/heads/master
Commit: 44bb92593444ee3bf22df32b16bcda96128dff4a
Parents: 3e09e66
Author: Timothy Bish <ta...@gmail.com>
Authored: Mon Aug 3 18:09:54 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Mon Aug 3 18:09:54 2015 -0400

----------------------------------------------------------------------
 .../activemq/commands/ActiveMQTextMessage.cpp   | 129 ++++++++++---------
 .../activemq/commands/ActiveMQTextMessage.h     |  37 +++---
 2 files changed, 85 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/44bb9259/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp b/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp
index 9269cce..45e164a 100644
--- a/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp
+++ b/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp
@@ -40,12 +40,14 @@ using namespace decaf::util;
 using namespace decaf::util::zip;
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQTextMessage::ActiveMQTextMessage() :
-    ActiveMQMessageTemplate<cms::TextMessage>(), text() {
+const unsigned char ActiveMQTextMessage::ID_ACTIVEMQTEXTMESSAGE = 28;
+
+////////////////////////////////////////////////////////////////////////////////
+ActiveMQTextMessage::ActiveMQTextMessage() : ActiveMQMessageTemplate<cms::TextMessage>(), text() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQTextMessage::~ActiveMQTextMessage() throw() {
+ActiveMQTextMessage::~ActiveMQTextMessage() throw () {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -55,31 +57,41 @@ unsigned char ActiveMQTextMessage::getDataStructureType() const {
 
 ////////////////////////////////////////////////////////////////////////////////
 ActiveMQTextMessage* ActiveMQTextMessage::cloneDataStructure() const {
-    std::auto_ptr<ActiveMQTextMessage> message( new ActiveMQTextMessage() );
-    message->copyDataStructure( this );
+    std::auto_ptr<ActiveMQTextMessage> message(new ActiveMQTextMessage());
+    message->copyDataStructure(this);
     return message.release();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQTextMessage::copyDataStructure( const DataStructure* src ) {
+cms::TextMessage* ActiveMQTextMessage::clone() const {
+    ActiveMQTextMessage* clone = this->cloneDataStructure();
+
+    clone->setReadOnlyBody(false);
+    clone->setReadOnlyProperties(false);
+
+    return dynamic_cast<cms::TextMessage*>(clone);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQTextMessage::copyDataStructure(const DataStructure* src) {
 
-    if( this == src ) {
+    if (this == src) {
         return;
     }
 
-    const ActiveMQTextMessage* srcPtr = dynamic_cast<const ActiveMQTextMessage*>( src );
+    const ActiveMQTextMessage* srcPtr = dynamic_cast<const ActiveMQTextMessage*>(src);
 
-    if( srcPtr == NULL || src == NULL ) {
+    if (srcPtr == NULL || src == NULL) {
         throw decaf::lang::exceptions::NullPointerException(
             __FILE__, __LINE__,
-            "ActiveMQTextMessage::copyDataStructure - src is NULL or invalid" );
+            "ActiveMQTextMessage::copyDataStructure - src is NULL or invalid");
     }
 
-    if( srcPtr->text.get() != NULL ) {
-        this->text.reset( new std::string( *( srcPtr->text.get() ) ) );
+    if (srcPtr->text.get() != NULL) {
+        this->text.reset(new std::string(*(srcPtr->text.get())));
     }
 
-    ActiveMQMessageTemplate<cms::TextMessage>::copyDataStructure( src );
+    ActiveMQMessageTemplate<cms::TextMessage>::copyDataStructure(src);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -89,73 +101,73 @@ std::string ActiveMQTextMessage::toString() const {
 
         std::string text = getText();
 
-        if( text != "" && text.length() > 63 ) {
+        if (text != "" && text.length() > 63) {
 
-            text = text.substr( 0, 45 ) + "..." + text.substr( text.length() - 12 );
+            text = text.substr(0, 45) + "..." + text.substr(text.length() - 12);
             return ActiveMQMessageTemplate<cms::TextMessage>::toString() + "Text = " + text;
         }
 
-    } catch( cms::CMSException& e ) {
+    } catch (cms::CMSException& e) {
     }
 
     return ActiveMQMessageTemplate<cms::TextMessage>::toString();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool ActiveMQTextMessage::equals( const DataStructure* value ) const {
-    return ActiveMQMessageTemplate<cms::TextMessage>::equals( value );
+bool ActiveMQTextMessage::equals(const DataStructure* value) const {
+    return ActiveMQMessageTemplate<cms::TextMessage>::equals(value);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQTextMessage::clearBody() {
     ActiveMQMessageTemplate<cms::TextMessage>::clearBody();
-    this->text.reset( NULL );
+    this->text.reset( NULL);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQTextMessage::beforeMarshal( wireformat::WireFormat* wireFormat ) {
+void ActiveMQTextMessage::beforeMarshal(wireformat::WireFormat* wireFormat) {
 
-    ActiveMQMessageTemplate<cms::TextMessage>::beforeMarshal( wireFormat );
+    ActiveMQMessageTemplate<cms::TextMessage>::beforeMarshal(wireFormat);
 
-    if( this->text.get() != NULL ) {
+    if (this->text.get() != NULL) {
 
         ByteArrayOutputStream* bytesOut = new ByteArrayOutputStream;
         OutputStream* os = bytesOut;
 
-        if( this->connection != NULL && this->connection->isUseCompression() ) {
+        if (this->connection != NULL && this->connection->isUseCompression()) {
             this->compressed = true;
-            Deflater* deflator = new Deflater( this->connection->getCompressionLevel() );
-            os = new DeflaterOutputStream( os, deflator, true, true );
+            Deflater* deflator = new Deflater(this->connection->getCompressionLevel());
+            os = new DeflaterOutputStream(os, deflator, true, true);
         }
 
-        DataOutputStream dataOut( os, true );
+        DataOutputStream dataOut(os, true);
 
-        if( this->text.get() == NULL ) {
-            dataOut.writeInt( -1 );
+        if (this->text.get() == NULL) {
+            dataOut.writeInt(-1);
         } else {
-            MarshallingSupport::writeString32( dataOut, *( this->text ) );
+            MarshallingSupport::writeString32(dataOut, *(this->text));
         }
 
         dataOut.close();
 
-        if( bytesOut->size() > 0 ) {
+        if (bytesOut->size() > 0) {
             std::pair<unsigned char*, int> array = bytesOut->toByteArray();
-            this->setContent( std::vector<unsigned char>( array.first, array.first + array.second ) );
-            delete [] array.first;
+            this->setContent(std::vector<unsigned char>(array.first, array.first + array.second));
+            delete[] array.first;
         }
 
-        this->text.reset( NULL );
+        this->text.reset(NULL);
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 unsigned int ActiveMQTextMessage::getSize() const {
 
-    if( this->text.get() != NULL ) {
+    if (this->text.get() != NULL) {
         unsigned int size = commands::Message::DEFAULT_MESSAGE_SIZE;
 
-        size += (unsigned int)getMarshalledProperties().size();
-        size += (unsigned int)this->text->size() * 2;
+        size += (unsigned int) getMarshalledProperties().size();
+        size += (unsigned int) this->text->size() * 2;
 
         return size;
     }
@@ -166,55 +178,52 @@ unsigned int ActiveMQTextMessage::getSize() const {
 ////////////////////////////////////////////////////////////////////////////////
 std::string ActiveMQTextMessage::getText() const {
 
-    try{
+    try {
 
-        if( this->text.get() != NULL ) {
-            return *( this->text.get() );
+        if (this->text.get() != NULL) {
+            return *(this->text.get());
         } else {
 
-            if( this->getContent().size() <= 4 ) {
+            if (this->getContent().size() <= 4) {
                 return "";
             }
 
             try {
 
-                InputStream* is = new ByteArrayInputStream( getContent() );
+                InputStream* is = new ByteArrayInputStream(getContent());
 
-                if( isCompressed() ) {
-                    is = new InflaterInputStream( is, true );
+                if (isCompressed()) {
+                    is = new InflaterInputStream(is, true);
                 }
 
-                DataInputStream dataIn( is, true );
+                DataInputStream dataIn(is, true);
 
-                this->text.reset( new std::string( MarshallingSupport::readString32( dataIn ) ) );
+                this->text.reset(new std::string(MarshallingSupport::readString32(dataIn)));
 
                 dataIn.close();
 
-            } catch( IOException& ioe ) {
-                throw CMSExceptionSupport::create( ioe );
+            } catch (IOException& ioe) {
+                throw CMSExceptionSupport::create(ioe);
             }
         }
 
-        return *( this->text.get() );
+        return *(this->text.get());
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
-}
+    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()}
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQTextMessage::setText( const char* msg ) {
+void ActiveMQTextMessage::setText(const char* msg) {
 
-    try{
-        setText( std::string(msg) );
+    try {
+        setText(std::string(msg));
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
-}
+    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()}
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQTextMessage::setText( const std::string& msg ) {
+void ActiveMQTextMessage::setText(const std::string& msg) {
 
-    try{
+    try {
         failIfReadOnlyBody();
-        this->text.reset( new std::string( msg ) );
+        this->text.reset(new std::string(msg));
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
-}
+    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()}

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/44bb9259/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h b/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h
index fbe2c4c..39dcbe6 100644
--- a/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h
+++ b/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h
@@ -25,59 +25,54 @@
 #include <string>
 #include <memory>
 
-namespace activemq{
-namespace commands{
+namespace activemq {
+namespace commands {
 
-    class AMQCPP_API ActiveMQTextMessage :
-        public ActiveMQMessageTemplate<cms::TextMessage> {
+    class AMQCPP_API ActiveMQTextMessage : public ActiveMQMessageTemplate<cms::TextMessage> {
     public:
 
-        const static unsigned char ID_ACTIVEMQTEXTMESSAGE = 28;
+        const static unsigned char ID_ACTIVEMQTEXTMESSAGE;
 
         mutable std::auto_ptr<std::string> text;
 
     private:
 
-        ActiveMQTextMessage( const ActiveMQTextMessage& );
-        ActiveMQTextMessage& operator= ( const ActiveMQTextMessage& );
+        ActiveMQTextMessage(const ActiveMQTextMessage&);
+        ActiveMQTextMessage& operator=(const ActiveMQTextMessage&);
 
     public:
 
         ActiveMQTextMessage();
-        virtual ~ActiveMQTextMessage() throw();
+
+        virtual ~ActiveMQTextMessage() throw ();
 
         virtual unsigned char getDataStructureType() const;
 
         virtual ActiveMQTextMessage* cloneDataStructure() const;
 
-        virtual void copyDataStructure( const DataStructure* src );
+        virtual void copyDataStructure(const DataStructure* src);
 
         virtual std::string toString() const;
 
-        virtual bool equals( const DataStructure* value ) const;
+        virtual bool equals(const DataStructure* value) const;
 
         virtual void clearBody();
 
-        virtual void beforeMarshal( wireformat::WireFormat* wireFormat );
+        virtual void beforeMarshal(wireformat::WireFormat* wireFormat);
 
         virtual unsigned int getSize() const;
 
-    public:   // CMS Message
+    public: // CMS Message
 
-        virtual cms::TextMessage* clone() const {
-            ActiveMQTextMessage* clone = this->cloneDataStructure();
-            clone->setReadOnlyBody(false);
-            clone->setReadOnlyProperties(false);
-            return dynamic_cast<cms::TextMessage*>(clone);
-        }
+        virtual cms::TextMessage* clone() const;
 
-    public:   // cms::TextMessage
+    public: // CMS TextMessage
 
         virtual std::string getText() const;
 
-        virtual void setText( const char* msg );
+        virtual void setText(const char* msg);
 
-        virtual void setText( const std::string& msg );
+        virtual void setText(const std::string& msg);
 
     };
 


[2/2] activemq-cpp git commit: Update the values of last delivered sequence defaults to match JMS client.

Posted by ta...@apache.org.
Update the values of last delivered sequence defaults to match JMS
client.

Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/54c3b9d2
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/54c3b9d2
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/54c3b9d2

Branch: refs/heads/master
Commit: 54c3b9d2987641fbf8d61e33a7a30b80e8ed423c
Parents: 44bb925
Author: Timothy Bish <ta...@gmail.com>
Authored: Mon Aug 3 18:25:00 2015 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Mon Aug 3 18:25:00 2015 -0400

----------------------------------------------------------------------
 activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp       | 2 +-
 .../src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp     | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/54c3b9d2/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
index cba5882..5858385 100644
--- a/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
+++ b/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
@@ -717,7 +717,7 @@ void ActiveMQConnection::close() {
             }
         }
 
-        long long lastDeliveredSequenceId = 0;
+        long long lastDeliveredSequenceId = -1;
 
         // Get the complete list of active sessions.
         try {

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/54c3b9d2/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
index 0329d61..f486964 100644
--- a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
+++ b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
@@ -203,7 +203,7 @@ ActiveMQSessionKernel::ActiveMQSessionKernel(ActiveMQConnection* connection,
                                                                              producerIds(),
                                                                              producerSequenceIds(),
                                                                              consumerIds(),
-                                                                             lastDeliveredSequenceId(0) {
+                                                                             lastDeliveredSequenceId(-2) {
 
     if (id == NULL || connection == NULL) {
         throw ActiveMQException(
@@ -225,8 +225,6 @@ ActiveMQSessionKernel::ActiveMQSessionKernel(ActiveMQConnection* connection,
         throw;
     }
 
-    this->closed.set(false);
-    this->lastDeliveredSequenceId = -1;
     this->config->sessionAsyncDispatch = connection->isAlwaysSessionAsync();
 
     // Create a Transaction object