On 08/26/2015 08:13 PM, Chaomei Lo wrote: > Thanks, Tim. > > Let me rephrase my question - is the Message class in the argument of > onMessage(...) under the 'cms' namespace ? So that I can write 'const > cms::Message* message' in below. That was what I used, but not work > properly.
All CMS API classes exists in the cms:: namespace. #include <cms/MessageListener.h> class MyConsumer : public cms::MessageListener { public: virtual void onMessage(const cms::Message* message); } > // Called from the consumer since this class is a registered > MessageListener. > virtual void onMessage(const Message* message) { > > On Wed, Aug 26, 2015 at 5:05 PM, Timothy Bish <tabish...@gmail.com> wrote: > >> On 08/26/2015 07:37 PM, mfan wrote: >>> I have constructed a customized Consumer class with the following line >>> (declare onMessage(..) in Consumer.hpp. >>> >>> /virtual void onMessage(const Message* message); >>> / >>> >>> I do not want to have "using namespace xxx" in header, so I need to >> identify >>> which Message object it passed to. I found a "Message.h" in >>> ~/activemq-cpp-library-3.8.4/src/main/cms, so I assume that it is, so I >>> added 'cms::' in above line, and thought it would solve the problem. >>> However, weird behavior happened, Instead of getting what the Producer >> has >>> just sent, the Consumer received something seems to be sent before. I >> have >>> restarted the CMS broker, it did not solve the problem. Did I use a >> wrong >>> namespace for Message ? >> It's not really clear what you did and what is happening so I can't say >> what might be the problem. >> >>> I checked the Message.h under 'cms' directory, it has 'CMS_API' >> declared >>> in front of the Message class, >>> >>> /class CMS_API Message { >>> / >>> What does the CMS_API do ? >> Ensures that on Windows the class has proper declspec exports for DLL >> interop >> >>> If I include all these following in header, then it works fine. >>> >>> /using namespace activemq::core; >>> using namespace decaf::util::concurrent; >>> using namespace decaf::util; >>> using namespace decaf::lang; >>> using namespace cms; >>> / >>> >>> Another question, in ActiveMQ-CPP example, there is an 'AMQCPP_UNUSED' >> pass >>> to the argument of the main() function. What does it mean ? >> Prevents the compiler on some platforms from emitting a warning that >> those args are not used as that is intentional. >> >>> Thanks. >>> >>> >>> >>> -- >>> View this message in context: >> http://activemq.2283324.n4.nabble.com/Is-Message-object-in-arugment-of-onMessage-under-the-cms-namespace-tp4701425.html >>> Sent from the ActiveMQ - User mailing list archive at Nabble.com. >>> >> >> -- >> Tim Bish >> Sr Software Engineer | RedHat Inc. >> tim.b...@redhat.com | www.redhat.com >> twitter: @tabish121 >> blog: http://timbish.blogspot.com/ >> >> -- Tim Bish Sr Software Engineer | RedHat Inc. tim.b...@redhat.com | www.redhat.com twitter: @tabish121 blog: http://timbish.blogspot.com/