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:
Matt Broadstone 2014-06-18 10:31:28 -04:00
parent b5d77e17e3
commit f5763ac9bb
32 changed files with 344 additions and 1 deletions

View File

@ -1,4 +1,5 @@
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS += src \ SUBDIRS += src \
tests tests \
tutorials
CONFIG += ordered CONFIG += ordered

View File

@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
send \
receive

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
receive_logs \
emit_log

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -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

View File

@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
emit_log_direct \
receive_logs_direct

4
tutorials/rpc/rpc.pro Normal file
View File

@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
rpc_server \
rpc_client

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -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

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -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

View File

@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
emit_log_topic \
receive_logs_topic

8
tutorials/tutorials.pro Normal file
View File

@ -0,0 +1,8 @@
TEMPLATE = subdirs
SUBDIRS = \
helloworld \
workqueues \
pubsub \
routing \
topics \
rpc

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -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

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "testing";
return EXIT_SUCCESS;
}

View File

@ -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

View File

@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = \
new_task \
worker