begin to add rabbitmq tutorials
most of these are included in the manual amqp test already, but I wanted to break them out so users could have a nice example of how to do these in standalone form, like the python tutorials. Helloworld (tutorial 1) is also included fully implemented in this commit
This commit is contained in:
parent
b5d77e17e3
commit
f5763ac9bb
|
|
@ -1,4 +1,5 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS += src \
|
||||
tests
|
||||
tests \
|
||||
tutorials
|
||||
CONFIG += ordered
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = \
|
||||
send \
|
||||
receive
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include "amqp_client.h"
|
||||
#include "amqp_exchange.h"
|
||||
#include "amqp_queue.h"
|
||||
using namespace QAMQP;
|
||||
|
||||
class Receiver : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Receiver(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
public Q_SLOTS:
|
||||
void start() {
|
||||
connect(&m_client, SIGNAL(connected()), this, SLOT(clientConnected()));
|
||||
m_client.connectToHost();
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void clientConnected() {
|
||||
Queue *queue = m_client.createQueue("hello");
|
||||
connect(queue, SIGNAL(declared()), this, SLOT(queueDeclared()));
|
||||
queue->declare();
|
||||
}
|
||||
|
||||
void queueDeclared() {
|
||||
Queue *queue = qobject_cast<Queue*>(sender());
|
||||
if (!queue)
|
||||
return;
|
||||
|
||||
connect(queue, SIGNAL(messageReceived()), this, SLOT(messageReceived()));
|
||||
queue->consume(Queue::coNoAck);
|
||||
qDebug() << " [*] Waiting for messages. To exit press CTRL+C";
|
||||
}
|
||||
|
||||
void messageReceived() {
|
||||
Queue *queue = qobject_cast<Queue*>(sender());
|
||||
if (!queue)
|
||||
return;
|
||||
|
||||
Message message = queue->dequeue();
|
||||
qDebug() << " [x] Received " << message.payload();
|
||||
}
|
||||
|
||||
private:
|
||||
Client m_client;
|
||||
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
Receiver receiver;
|
||||
receiver.start();
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
#include "amqp_client.h"
|
||||
#include "amqp_exchange.h"
|
||||
#include "amqp_queue.h"
|
||||
using namespace QAMQP;
|
||||
|
||||
class Sender : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Sender(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
public Q_SLOTS:
|
||||
void start() {
|
||||
connect(&m_client, SIGNAL(connected()), this, SLOT(clientConnected()));
|
||||
m_client.connectToHost();
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void clientConnected() {
|
||||
Queue *queue = m_client.createQueue("hello");
|
||||
connect(queue, SIGNAL(declared()), this, SLOT(queueDeclared()));
|
||||
queue->declare();
|
||||
}
|
||||
|
||||
void queueDeclared() {
|
||||
Queue *queue = qobject_cast<Queue*>(sender());
|
||||
if (!queue)
|
||||
return;
|
||||
Exchange *defaultExchange = m_client.createExchange();
|
||||
defaultExchange->publish("Hello World!", "hello");
|
||||
qDebug() << " [x] Sent 'Hello World!'";
|
||||
QTimer::singleShot(25, qApp, SLOT(quit()));
|
||||
}
|
||||
|
||||
private:
|
||||
Client m_client;
|
||||
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
Sender sender;
|
||||
sender.start();
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = \
|
||||
receive_logs \
|
||||
emit_log
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = \
|
||||
emit_log_direct \
|
||||
receive_logs_direct
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = \
|
||||
rpc_server \
|
||||
rpc_client
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = \
|
||||
emit_log_topic \
|
||||
receive_logs_topic
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = \
|
||||
helloworld \
|
||||
workqueues \
|
||||
pubsub \
|
||||
routing \
|
||||
topics \
|
||||
rpc
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
qDebug() << "testing";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += $${QAMQP_INCLUDEPATH}
|
||||
LIBS += -L$${DEPTH}/src $${QAMQP_LIBS}
|
||||
macx:CONFIG -= app_bundle
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = \
|
||||
new_task \
|
||||
worker
|
||||
Loading…
Reference in New Issue