2014-05-29 00:25:28 +08:00
|
|
|
#ifndef amqp_queue_h__
|
|
|
|
|
#define amqp_queue_h__
|
|
|
|
|
|
2014-06-10 21:05:42 +08:00
|
|
|
#include <QQueue>
|
|
|
|
|
|
2014-05-29 00:25:28 +08:00
|
|
|
#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-10 21:05:42 +08:00
|
|
|
class QAMQP_EXPORT Queue : public Channel, public QQueue<Message>
|
2014-05-29 00:25:28 +08:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_ENUMS(QueueOptions)
|
2014-06-07 00:10:51 +08:00
|
|
|
Q_PROPERTY(int options READ options CONSTANT)
|
2014-05-29 00:25:28 +08:00
|
|
|
Q_PROPERTY(QString consumerTag READ consumerTag WRITE setConsumerTag)
|
|
|
|
|
Q_PROPERTY(bool noAck READ noAck WRITE setNoAck)
|
2014-06-07 00:10:51 +08:00
|
|
|
Q_ENUMS(QueueOption)
|
|
|
|
|
Q_ENUMS(ConsumeOption)
|
|
|
|
|
Q_ENUMS(RemoveOption)
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum QueueOption {
|
|
|
|
|
NoOptions = 0x0,
|
|
|
|
|
Passive = 0x01,
|
|
|
|
|
Durable = 0x02,
|
2014-06-24 03:36:03 +08:00
|
|
|
Exclusive = 0x04,
|
|
|
|
|
AutoDelete = 0x08,
|
2014-05-29 00:25:28 +08:00
|
|
|
NoWait = 0x10
|
|
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(QueueOptions, QueueOption)
|
2014-06-07 00:10:51 +08:00
|
|
|
int options() const;
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
enum ConsumeOption {
|
2014-06-24 03:36:03 +08:00
|
|
|
coNoLocal = 0x01,
|
2014-05-29 00:25:28 +08:00
|
|
|
coNoAck = 0x02,
|
|
|
|
|
coExclusive = 0x04,
|
2014-06-24 03:36:03 +08:00
|
|
|
coNoWait = 0x08
|
2014-05-29 00:25:28 +08:00
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(ConsumeOptions, ConsumeOption)
|
|
|
|
|
|
2014-06-07 00:10:51 +08:00
|
|
|
enum RemoveOption {
|
2014-06-11 09:27:59 +08:00
|
|
|
roForce = 0x0,
|
2014-06-24 03:36:03 +08:00
|
|
|
roIfUnused = 0x01,
|
2014-06-07 00:10:51 +08:00
|
|
|
roIfEmpty = 0x02,
|
|
|
|
|
roNoWait = 0x04
|
|
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(RemoveOptions, RemoveOption)
|
|
|
|
|
|
2014-05-29 00:25:28 +08:00
|
|
|
~Queue();
|
|
|
|
|
|
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-06-07 01:37:36 +08:00
|
|
|
void declare(int options = 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();
|
2014-06-07 00:10:51 +08:00
|
|
|
void remove(int options = roIfUnused|roIfEmpty|roNoWait);
|
2014-05-29 00:25:28 +08:00
|
|
|
|
2014-06-06 02:10:29 +08:00
|
|
|
// AMQP Basic
|
2014-06-07 00:10:51 +08:00
|
|
|
void consume(int options = 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();
|
2014-06-11 01:04:57 +08:00
|
|
|
void purged(int messageCount);
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
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-06-07 00:10:51 +08:00
|
|
|
explicit 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
|