本文整理汇总了C++中MessageQueue::Send方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageQueue::Send方法的具体用法?C++ MessageQueue::Send怎么用?C++ MessageQueue::Send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageQueue
的用法示例。
在下文中一共展示了MessageQueue::Send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(MessageQueueTest, test)
{
MessageQueue que;
int count = 0;
que.Send(std::make_shared<MessagePost>([&] {
std::cout << "timeout" << std::endl;
count++;
}));
std::shared_ptr<Message> msg = que.Receive();
ASSERT_EQ(msg->ID(), MessageID::Post);
MessagePost* post = static_cast<MessagePost*>(msg.get());
post->Func();
ASSERT_EQ(count , 1);
}
示例2: main
int main(int argc, char *argv[])
{
string sAccNbr;
cout<<"请输入支付号码,其他信息默认:"<<endl;
cin>>sAccNbr;
ABMException oExp;
AbmPayCond oCmd;
strcpy(oCmd.m_sOperatype, "hello world");
strcpy(oCmd.m_sOperateSeq, "1234567");
strcpy(oCmd.m_sSpID, "543");
strcpy(oCmd.m_sServicePlatformID, "321");
strcpy(oCmd.m_sPayPassword, "password");
strcpy(oCmd.m_sRandomPassword, "password");
strcpy(oCmd.m_sDestinationAccount, sAccNbr.c_str());
strcpy(oCmd.m_sOrderID, "13579");
strcpy(oCmd.m_sDescription, "支付测试");
strcpy(oCmd.m_sSpID, "9876");
oCmd.m_lPayAmount=7;
oCmd.m_iOperateAction = 8;
oCmd.m_iPayDate = 20110531193030;
AbmPaymentCCR oCCR;
AbmPaymentCCA oCCA;
oCCR.clear();
if (!oCCR.addPayInfo(oCmd)) {
cout<<"pack failed!"<<endl;
return -1;
}
MessageQueue *pMQ = new MessageQueue(11005);
if (pMQ->open(oExp, true, true) != 0) {
cout<<"pMQ->open failed!"<<endl;
return -1;
}
MessageQueue *pMQ2 = new MessageQueue(11006);
if (pMQ2->open(oExp, true, true) != 0) {
cout<<"pMQ->open failed!"<<endl;
return -1;
}
if (pMQ->Send((void *)&oCCR, oCCR.m_iSize) <= 0) {
cout<<"pMQ->Send failed!"<<endl;
return -1;
}
oCCA.clear();
if (pMQ2->Receive((void *)&oCCA, sizeof(oCCA), 0) <= 0) {
cout<<"pMQ->Receive failed!"<<endl;
return -1;
}
vector<ResponsPayOne*> vRes;
vector<ResponsPayTwo*> vData;
vRes.clear();
vData.clear();
if (oCCA.getRespons(vRes) <= 0) {
cout<<"oCCA->getRespons failed!"<<endl;
return -1;
}
for (int i=0; i<vRes.size(); ++i) {
cout<<"业务处理码="<<vRes[i]->m_iRltCode<<endl;
vData.clear();
if(vRes[i]->m_iRltCode==0)
{
if (oCCA.getPayData(vRes[i], vData) <= 0) {
cout<<"getServData failed!"<<endl;
return -1;
}
for (int j=0; j<vData.size(); ++j) {
cout<<"m_sOperateSeq="<<vData[j]->m_sOperateSeq<<endl;
cout<<"m_sReqSerial="<<vData[j]->m_sReqSerial<<endl;
}
}
}
return 0;
}