本文整理汇总了C++中Topic::getUID方法的典型用法代码示例。如果您正苦于以下问题:C++ Topic::getUID方法的具体用法?C++ Topic::getUID怎么用?C++ Topic::getUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::getUID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
try {
BaseTestCase::startTest(argv);
// create Admin and connect
XoramAdmin* admin = new XoramAdmin();
admin->connect("root", "root", 60);
// create destination
Queue* queue = admin->createQueue("queue");
printf("queue->getUID() = %s, queue->getName() = %s\n",queue->getUID(), queue->getName());
Topic* topic = admin->createTopic("topic");
printf("topic->getUID() = %s, topic->getName() = %s\n",topic->getUID(), topic->getName());
// set right
admin->setFreeReading(queue);
admin->setFreeWriting(queue);
admin->setFreeReading(topic);
admin->setFreeWriting(topic);
// create "anonymous" user
admin->createUser("anonymous", "anonymous");
ConnectionFactory* cf = new TCPConnectionFactory("localhost", 16010);
Connection* cnx = cf->createConnection("anonymous", "anonymous");
cnx->start();
Session* sess = cnx->createSession();
MessageProducer* prod1 = sess->createProducer(queue);
MessageProducer* prod2 = sess->createProducer(topic);
MessageConsumer* cons1 = sess->createConsumer(queue);
MessageConsumer* cons2 = sess->createConsumer(topic);
Message* msg1 = sess->createMessage();
prod1->send(msg1);
printf("##### Message sent on queue: %s\n", msg1->getMessageID());
Message* msg2 = sess->createMessage();
prod2->send(msg2);
printf("##### Message sent on topic: %s\n", msg2->getMessageID());
Message* msg = cons1->receive();
printf("##### Message received from queue: %s\n", msg->getMessageID());
msg = cons2->receive();
printf("##### Message received from tpoic: %s\n", msg->getMessageID());
// delete User
CreateUserReply* userReply = admin->createUser("removeUser", "removeUser");
admin->deleteUser("removeUser",userReply->getProxId());
// delete Queue and Topic
printf("delete Queue %s\n", queue->getUID());
admin->deleteDestination(queue->getUID());
printf("delete Topic %s\n", topic->getUID());
admin->deleteDestination(topic->getUID());
admin->disconnect();
cnx->close();
} catch (Exception exc) {
printf("##### exception - %s", exc.getMessage());
BaseTestCase::error(&exc);
} catch (...) {
printf("##### exception\n");
BaseTestCase::error(new Exception(" catch ..., unknown exception "));
}
printf("##### bye\n");
BaseTestCase::endTest();
}