add support for Basic.Reject

This adds the reject method to QAmqpQueue in order to reject an
incoming message, and conditionally requeue it.
This commit is contained in:
Matt Broadstone 2015-02-01 09:49:39 -05:00
parent e6b69010e4
commit d051f5a445
2 changed files with 28 additions and 1 deletions

View File

@ -533,6 +533,32 @@ void QAmqpQueue::ack(qlonglong deliveryTag, bool multiple)
d->sendFrame(frame);
}
void QAmqpQueue::reject(const QAmqpMessage &message, bool requeue)
{
ack(message.deliveryTag(), requeue);
}
void QAmqpQueue::reject(qlonglong deliveryTag, bool requeue)
{
Q_D(QAmqpQueue);
if (!d->opened) {
qAmqpDebug() << Q_FUNC_INFO << "channel is not open";
return;
}
QAmqpMethodFrame frame(QAmqpFrame::Basic, QAmqpQueuePrivate::bmReject);
frame.setChannel(d->channelNumber);
QByteArray arguments;
QDataStream out(&arguments, QIODevice::WriteOnly);
out << deliveryTag;
out << qint8(requeue ? 1 : 0);
frame.setArguments(arguments);
d->sendFrame(frame);
}
bool QAmqpQueue::cancel(bool noWait)
{
Q_D(QAmqpQueue);

View File

@ -70,9 +70,10 @@ public:
bool consume(int options = NoOptions);
void get(bool noAck = true);
bool cancel(bool noWait = false);
void ack(const QAmqpMessage &message);
void ack(qlonglong deliveryTag, bool multiple);
void reject(const QAmqpMessage &message, bool requeue);
void reject(qlonglong deliveryTag, bool requeue);
Q_SIGNALS:
void declared();