handle messages with empty payloads
If a message is delivered with an empty body, we were not previously enqueuing the message. This fixes issue #43
This commit is contained in:
parent
6a3d355de2
commit
84746ff77c
|
|
@ -78,6 +78,7 @@ bool QueuePrivate::_q_method(const Frame::Method &frame)
|
||||||
|
|
||||||
void QueuePrivate::_q_content(const Frame::Content &frame)
|
void QueuePrivate::_q_content(const Frame::Content &frame)
|
||||||
{
|
{
|
||||||
|
Q_Q(Queue);
|
||||||
Q_ASSERT(frame.channel() == channelNumber);
|
Q_ASSERT(frame.channel() == channelNumber);
|
||||||
if (frame.channel() != channelNumber)
|
if (frame.channel() != channelNumber)
|
||||||
return;
|
return;
|
||||||
|
|
@ -96,6 +97,12 @@ void QueuePrivate::_q_content(const Frame::Content &frame)
|
||||||
currentMessage.d->headers = (it.value()).toHash();
|
currentMessage.d->headers = (it.value()).toHash();
|
||||||
currentMessage.d->properties[property] = it.value();
|
currentMessage.d->properties[property] = it.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentMessage.d->leftSize == 0) {
|
||||||
|
// message with an empty body
|
||||||
|
q->enqueue(currentMessage);
|
||||||
|
Q_EMIT q->messageReceived();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueuePrivate::_q_body(const Frame::ContentBody &frame)
|
void QueuePrivate::_q_body(const Frame::ContentBody &frame)
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ private Q_SLOTS:
|
||||||
void invalidRoutingKey();
|
void invalidRoutingKey();
|
||||||
void tableFieldDataTypes();
|
void tableFieldDataTypes();
|
||||||
void messageProperties();
|
void messageProperties();
|
||||||
|
void emptyMessage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Client> client;
|
QScopedPointer<Client> client;
|
||||||
|
|
@ -639,5 +640,19 @@ void tst_QAMQPQueue::messageProperties()
|
||||||
QCOMPARE(message.property(Message::ClusterID).toString(), QLatin1String("some-cluster-id"));
|
QCOMPARE(message.property(Message::ClusterID).toString(), QLatin1String("some-cluster-id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QAMQPQueue::emptyMessage()
|
||||||
|
{
|
||||||
|
Queue *queue = client->createQueue("test-issue-43");
|
||||||
|
declareQueueAndVerifyConsuming(queue);
|
||||||
|
|
||||||
|
Exchange *defaultExchange = client->createExchange();
|
||||||
|
defaultExchange->publish("", "test-issue-43");
|
||||||
|
|
||||||
|
QVERIFY(waitForSignal(queue, SIGNAL(messageReceived())));
|
||||||
|
Message message = queue->dequeue();
|
||||||
|
verifyStandardMessageHeaders(message, "test-issue-43");
|
||||||
|
QVERIFY(message.payload().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QAMQPQueue)
|
QTEST_MAIN(tst_QAMQPQueue)
|
||||||
#include "tst_qamqpqueue.moc"
|
#include "tst_qamqpqueue.moc"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue