If you want to do things the pure C++ way then you can play around with using the typeid operator from C++ RTTI to inspect the object to see what it is.
A simpler way is to cast to the underlying message type that all CMS Message instances are derived from:
activemq::core::commands::Message
This class offers a method getDataStructureType()
methods that returns the type via an assigned ID used in the OpenWire protocol:
const unsigned char ID_ACTIVEMQBLOBMESSAGE = 29;
const unsigned char ID_ACTIVEMQBYTESMESSAGE = 24;
const unsigned char ID_ACTIVEMQMAPMESSAGE = 25;
const unsigned char ID_ACTIVEMQMESSAGE = 23;
const unsigned char ID_ACTIVEMQOBJECTMESSAGE = 26;
const unsigned char ID_ACTIVEMQSTREAMMESSAGE = 27;
const unsigned char ID_ACTIVEMQTEXTMESSAGE = 28;
Or you can just try a dynamic cast to each type until the result is non-null.