今天我尝试为我发送的消息设计时间戳,我在函数中使用的代码如下:
void MainWindow::buttonClickHandler()
{
QString qs;
qs=ui->lineEdit->text();
std::string m_text=qs.toStdString();
//std::string m_text = ui->lineEdit->text();
// Customized message
long long startTime = System::currentTimeMillis();
try{
std::auto_ptr<TextMessage> message(m_IfacomMessageBroker->getSession()->createTextMessage(m_text));
//message->setCMSTimestamp(System::currentTimeMillis());
//m_IfacomMessageBroker->sendMessage(message);
m_IfacomMessageBroker->sendMessage("test");
long long ltest = m_IfacomAmqProducer->getSenderTimestamp(message);
QDateTime *dt = new QDateTime();
dt->setMSecsSinceEpoch(ltest);
QString qtstring1 = dt->toString("dd.MM.yyyy hh:mm:ss.zzz");
} catch (CMSException& e) {
e.printStackTrace();
}
long long endTime = System::currentTimeMillis();
double totalTime = (double)(endTime - startTime) / 1000.0;
}
void MainWindow::on_pushButton_3_clicked()
{
m_IfacomMessageBroker->close();
}
当我尝试构建解决方案时,出现此错误:
Error 12 error C2664: 'IfacomAmqSender::getSenderTimestamp' : cannot convert parameter 1 from 'std::auto_ptr<_Ty>' to 'const cms::Message *' C:\Users\Marco\Desktop\Activemq\ReleaseVersions\GUI-CMS-SENDER\mainwindow.cpp 105 1 GUI-CMS-SENDER
但奇怪的是我在另一个.cpp文件中没有问题地使用这个函数!!!
答案 0 :(得分:2)
说m_IfacomAmqProducer->getSenderTimestamp(message.get())
。