2014-08-27 03:05:39 +08:00
|
|
|
#ifndef QAMQPEXCHANGE_H
|
|
|
|
|
#define QAMQPEXCHANGE_H
|
2014-05-29 00:25:28 +08:00
|
|
|
|
2014-08-27 03:05:39 +08:00
|
|
|
#include "qamqptable.h"
|
|
|
|
|
#include "qamqpchannel.h"
|
|
|
|
|
#include "qamqpmessage.h"
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
namespace QAMQP
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class Client;
|
|
|
|
|
class Queue;
|
|
|
|
|
class ClientPrivate;
|
|
|
|
|
class ExchangePrivate;
|
2014-05-29 03:33:15 +08:00
|
|
|
class QAMQP_EXPORT Exchange : public Channel
|
2014-05-29 00:25:28 +08:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2014-06-11 09:23:08 +08:00
|
|
|
Q_PROPERTY(QString type READ type CONSTANT)
|
|
|
|
|
Q_PROPERTY(ExchangeOptions options READ options CONSTANT)
|
|
|
|
|
Q_ENUMS(ExchangeOptions)
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
public:
|
2014-06-02 22:59:10 +08:00
|
|
|
enum ExchangeType {
|
|
|
|
|
Direct,
|
|
|
|
|
FanOut,
|
|
|
|
|
Topic,
|
|
|
|
|
Headers
|
|
|
|
|
};
|
|
|
|
|
QString type() const;
|
|
|
|
|
|
2014-06-24 03:36:03 +08:00
|
|
|
enum PublishOption {
|
|
|
|
|
poNoOptions = 0x0,
|
|
|
|
|
poMandatory = 0x01,
|
|
|
|
|
poImmediate = 0x02
|
|
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(PublishOptions, PublishOption)
|
|
|
|
|
|
2014-06-11 09:41:28 +08:00
|
|
|
enum RemoveOption {
|
|
|
|
|
roForce = 0x0,
|
2014-06-24 03:36:03 +08:00
|
|
|
roIfUnused = 0x01,
|
2014-06-11 09:41:28 +08:00
|
|
|
roNoWait = 0x04
|
|
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(RemoveOptions, RemoveOption)
|
|
|
|
|
|
2014-05-29 00:25:28 +08:00
|
|
|
enum ExchangeOption {
|
|
|
|
|
NoOptions = 0x0,
|
|
|
|
|
Passive = 0x01,
|
|
|
|
|
Durable = 0x02,
|
2014-06-24 03:36:03 +08:00
|
|
|
AutoDelete = 0x04,
|
|
|
|
|
Internal = 0x08,
|
2014-05-29 00:25:28 +08:00
|
|
|
NoWait = 0x10
|
|
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(ExchangeOptions, ExchangeOption)
|
2014-06-11 09:23:08 +08:00
|
|
|
ExchangeOptions options() const;
|
2014-05-29 00:25:28 +08:00
|
|
|
|
2014-06-04 21:46:15 +08:00
|
|
|
virtual ~Exchange();
|
2014-06-05 11:44:07 +08:00
|
|
|
|
|
|
|
|
// AMQP Exchange
|
2014-06-02 22:59:10 +08:00
|
|
|
void declare(ExchangeType type = Direct,
|
|
|
|
|
ExchangeOptions options = NoOptions,
|
2014-08-04 04:39:31 +08:00
|
|
|
const Table &args = Table());
|
2014-05-29 00:25:28 +08:00
|
|
|
void declare(const QString &type = QLatin1String("direct"),
|
2014-05-31 04:56:29 +08:00
|
|
|
ExchangeOptions options = NoOptions,
|
2014-08-04 04:39:31 +08:00
|
|
|
const Table &args = Table());
|
2014-06-11 09:41:28 +08:00
|
|
|
void remove(int options = roIfUnused|roNoWait);
|
2014-05-29 00:25:28 +08:00
|
|
|
|
2014-06-05 11:44:07 +08:00
|
|
|
// AMQP Basic
|
2014-06-18 03:14:23 +08:00
|
|
|
void publish(const QString &message, const QString &routingKey,
|
2014-08-26 21:57:08 +08:00
|
|
|
const Message::PropertyHash &properties = Message::PropertyHash(),
|
2014-06-24 03:36:03 +08:00
|
|
|
int publishOptions = poNoOptions);
|
2014-08-26 21:57:08 +08:00
|
|
|
void publish(const QByteArray &message, const QString &routingKey, const QString &mimeType,
|
|
|
|
|
const Message::PropertyHash &properties = Message::PropertyHash(),
|
2014-06-24 03:36:03 +08:00
|
|
|
int publishOptions = poNoOptions);
|
2014-06-18 03:14:23 +08:00
|
|
|
void publish(const QByteArray &message, const QString &routingKey,
|
2014-08-04 04:39:31 +08:00
|
|
|
const QString &mimeType, const Table &headers,
|
2014-08-26 21:57:08 +08:00
|
|
|
const Message::PropertyHash &properties = Message::PropertyHash(),
|
2014-06-24 03:36:03 +08:00
|
|
|
int publishOptions = poNoOptions);
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void declared();
|
|
|
|
|
void removed();
|
|
|
|
|
|
|
|
|
|
protected:
|
2014-06-04 01:00:25 +08:00
|
|
|
virtual void channelOpened();
|
|
|
|
|
virtual void channelClosed();
|
2014-05-29 00:25:28 +08:00
|
|
|
|
|
|
|
|
private:
|
2014-05-30 23:12:09 +08:00
|
|
|
explicit Exchange(int channelNumber = -1, Client *parent = 0);
|
2014-05-29 01:52:27 +08:00
|
|
|
|
2014-05-29 00:25:28 +08:00
|
|
|
Q_DISABLE_COPY(Exchange)
|
2014-05-29 01:52:27 +08:00
|
|
|
Q_DECLARE_PRIVATE(Exchange)
|
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
|
|
|
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QAMQP::Exchange::ExchangeOptions)
|
2014-06-02 22:59:10 +08:00
|
|
|
Q_DECLARE_METATYPE(QAMQP::Exchange::ExchangeType)
|
2014-05-29 00:25:28 +08:00
|
|
|
|
2014-08-27 03:05:39 +08:00
|
|
|
#endif // QAMQPEXCHANGE_H
|