show example of queued calls on QAmqpExchange
This gives an example of how you can use QMetaObject::invokeMethod to call a QAmqpExchange from another thread. Also, moved the qRegisterMetaType for QAmqpMessage::PropertyHash to the ctor of QAmqpClientPrivate
This commit is contained in:
parent
4379e991c6
commit
a4bc1b5f4e
|
|
@ -31,6 +31,7 @@ QAmqpClientPrivate::QAmqpClientPrivate(QAmqpClient *q)
|
|||
error(QAMQP::NoError),
|
||||
q_ptr(q)
|
||||
{
|
||||
qRegisterMetaType<QAmqpMessage::PropertyHash>();
|
||||
}
|
||||
|
||||
QAmqpClientPrivate::~QAmqpClientPrivate()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ QAmqpMessagePrivate::QAmqpMessagePrivate()
|
|||
: deliveryTag(0),
|
||||
leftSize(0)
|
||||
{
|
||||
qRegisterMetaType<QAmqpMessage::PropertyHash>("QAmqpMessage::PropertyHash");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ private Q_SLOTS:
|
|||
void confirmDontLoseMessages();
|
||||
void passiveDeclareNotFound();
|
||||
void cleanupOnDeletion();
|
||||
void testQueuedPublish();
|
||||
|
||||
private:
|
||||
QScopedPointer<QAmqpClient> client;
|
||||
|
|
@ -217,5 +218,22 @@ void tst_QAMQPExchange::cleanupOnDeletion()
|
|||
QVERIFY(waitForSignal(exchange, SIGNAL(closed())));
|
||||
}
|
||||
|
||||
void tst_QAMQPExchange::testQueuedPublish()
|
||||
{
|
||||
QAmqpExchange *defaultExchange = client->createExchange();
|
||||
defaultExchange->enableConfirms();
|
||||
QVERIFY(waitForSignal(defaultExchange, SIGNAL(confirmsEnabled())));
|
||||
|
||||
QAmqpMessage::PropertyHash properties;
|
||||
properties[QAmqpMessage::DeliveryMode] = "2"; // make message persistent
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
QMetaObject::invokeMethod(defaultExchange, "publish", Qt::QueuedConnection,
|
||||
Q_ARG(QString, "noop"), Q_ARG(QString, "confirms-test"),
|
||||
Q_ARG(QAmqpMessage::PropertyHash, properties));
|
||||
}
|
||||
|
||||
QVERIFY(defaultExchange->waitForConfirms());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAMQPExchange)
|
||||
#include "tst_qamqpexchange.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue