Activemq现在不单单有了CMS、还开发了NMS,CMS专门为C++编写ActiveMQ客户端提供方便,NMS则是为.net平台下的ActiveMQ的客户端提供开发接口,可谓ActiveMQ发展的神速啊,难怪IONA都要把自己绑到这个平台上来呢。
今天同事让给个CMS配置Property的例子,节选了部分代码,以飨网友们。
cms::Session* pSession;
cms::BytesMessage* pMessage;
std::string strType;
std::string strID;
std::string strSerial;
std::string strMsgText;
....
try{
pMessage= pSession->createBytesMessage();
pMessage->setCMSType(strType);
pMessage->setStringProperty("ID", strID);
pMessage->setStringProperty("Serial", strSerial);
//Writes an ASCII String to the Bytes message stream.
pMessage->writeString(strMsgText);
//Writes an UTF String to the BytesMessage stream.
pMessage->writeUTF(strMsgText);
//TODO: to do something else
delete pMessage;
}
catch(cms::CMSException &ex)
{
ex.printStackTrace();
}
注意上边的writeUTF和writeString的区别。不用说啥了,上边的英文相信诸位都能看明白。