2014-05-29 00:25:28 +08:00
|
|
|
#ifndef amqp_queue_h__
|
|
|
|
|
#define amqp_queue_h__
|
|
|
|
|
|
|
|
|
|
#include "amqp_channel.h"
|
|
|
|
|
#include "amqp_message.h"
|
2014-05-29 03:33:15 +08:00
|
|
|
#include "amqp_global.h"
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
namespace QAMQP
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class Client;
|
|
|
|
|
class ClientPrivate;
|
|
|
|
|
class Exchange;
|
|
|
|
|
class QueuePrivate;
|
2014-06-04 21:46:15 +08:00
|
|
|
class QAMQP_EXPORT Queue : public Channel
|
2014-05-29 00:25:28 +08:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_ENUMS(QueueOptions)
|
|
|
|
|
Q_PROPERTY(QueueOptions option READ option)
|
|
|
|
|
Q_PROPERTY(QString consumerTag READ consumerTag WRITE setConsumerTag)
|
|
|
|
|
Q_PROPERTY(bool noAck READ noAck WRITE setNoAck)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum QueueOption {
|
|
|
|
|
NoOptions = 0x0,
|
|
|
|
|
Passive = 0x01,
|
|
|
|
|
Durable = 0x02,
|
|
|
|
|
Exclusive = 0x4,
|
|
|
|
|
AutoDelete = 0x8,
|
|
|
|
|
NoWait = 0x10
|
|
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(QueueOptions, QueueOption)
|
|
|
|
|
|
|
|
|
|
enum ConsumeOption {
|
|
|
|
|
coNoLocal = 0x1,
|
|
|
|
|
coNoAck = 0x02,
|
|
|
|
|
coExclusive = 0x04,
|
|
|
|
|
coNoWait = 0x8
|
|
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(ConsumeOptions, ConsumeOption)
|
|
|
|
|
|
|
|
|
|
~Queue();
|
|
|
|
|
QueueOptions option() const;
|
|
|
|
|
|
2014-06-06 02:10:29 +08:00
|
|
|
bool hasMessage() const;
|
2014-06-06 03:34:08 +08:00
|
|
|
Message getMessage();
|
2014-06-06 02:10:29 +08:00
|
|
|
|
|
|
|
|
void setConsumerTag(const QString &consumerTag);
|
|
|
|
|
QString consumerTag() const;
|
|
|
|
|
|
|
|
|
|
void setNoAck(bool noAck);
|
|
|
|
|
bool noAck() const;
|
|
|
|
|
|
|
|
|
|
// AMQP Queue
|
2014-05-31 03:36:11 +08:00
|
|
|
void declare(const QString &name = QString(),
|
|
|
|
|
QueueOptions options = QueueOptions(Durable | AutoDelete));
|
2014-05-30 23:12:09 +08:00
|
|
|
void bind(const QString &exchangeName, const QString &key);
|
|
|
|
|
void bind(Exchange *exchange, const QString &key);
|
|
|
|
|
void unbind(const QString &exchangeName, const QString &key);
|
|
|
|
|
void unbind(Exchange *exchange, const QString &key);
|
2014-06-06 02:10:29 +08:00
|
|
|
void purge();
|
|
|
|
|
void remove(bool ifUnused = true, bool ifEmpty = true, bool noWait = true);
|
2014-05-29 00:25:28 +08:00
|
|
|
|
2014-06-06 02:10:29 +08:00
|
|
|
// AMQP Basic
|
|
|
|
|
void consume(ConsumeOptions options = ConsumeOptions(NoOptions));
|
2014-05-29 00:25:28 +08:00
|
|
|
void get();
|
2014-06-06 03:34:08 +08:00
|
|
|
void ack(const Message &message);
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void declared();
|
2014-05-31 03:40:38 +08:00
|
|
|
void bound();
|
|
|
|
|
void unbound();
|
2014-05-29 00:25:28 +08:00
|
|
|
void removed();
|
2014-06-06 03:40:17 +08:00
|
|
|
void messageReceived();
|
2014-05-29 00:25:28 +08:00
|
|
|
void empty();
|
|
|
|
|
|
|
|
|
|
protected:
|
2014-06-04 01:00:25 +08:00
|
|
|
// reimp Channel
|
|
|
|
|
virtual void channelOpened();
|
|
|
|
|
virtual void channelClosed();
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
private:
|
2014-05-30 23:12:09 +08:00
|
|
|
Queue(int channelNumber = -1, Client *parent = 0);
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
Q_DISABLE_COPY(Queue)
|
2014-05-29 01:52:27 +08:00
|
|
|
Q_DECLARE_PRIVATE(Queue)
|
2014-05-29 00:25:28 +08:00
|
|
|
|
2014-05-30 02:10:38 +08:00
|
|
|
friend class Client;
|
2014-05-29 00:25:28 +08:00
|
|
|
};
|
|
|
|
|
|
2014-05-29 01:52:27 +08:00
|
|
|
} // namespace QAMQP
|
|
|
|
|
|
2014-05-29 00:25:28 +08:00
|
|
|
#endif
|