Comments (3)
@PaguaToP you're going to have to provide more context or source code for your issue. I actually originally used this library in a project that used QtService, so I know that it works. It is likely you are having issues with threads or something similar - a code sample would probably resolve this.
from qamqp.
My code
Receiver from examples:
class Receiver : public QObject
{
Q_OBJECT
public:
Receiver(QObject *parent = 0) : QObject(parent) {
m_client.setAutoReconnect(true);
}
public Q_SLOTS:
void start() {
connect(&m_client, SIGNAL(connected()), this, SLOT(clientConnected()));
m_client.connectToHost("myconnectstring");
}
private Q_SLOTS:
void clientConnected() {
QAmqpQueue *queue = m_client.createQueue("hello");
disconnect(queue, 0, 0, 0); // in case this is a reconnect
connect(queue, SIGNAL(declared()), this, SLOT(queueDeclared()));
queue->declare();
}
void queueDeclared() {
QAmqpQueue *queue = qobject_cast<QAmqpQueue*>(sender());
if (!queue)
return;
connect(queue, SIGNAL(messageReceived()), this, SLOT(messageReceived()));
queue->consume(QAmqpQueue::coNoAck);
qDebug() << " [*] Waiting for messages. To exit press CTRL+C";
}
void messageReceived() {
QAmqpQueue *queue = qobject_cast<QAmqpQueue*>(sender());
if (!queue)
return;
QAmqpMessage message = queue->dequeue();
qDebug() << " [x] Received " << message.payload();
}
private:
QAmqpClient m_client;
};
My Service class:
class QAService : public QtService<QCoreApplication>
{
public:
QAService(int argc, char *argv[]) : QtService<QCoreApplication>(argc, argv, "Qa Spider")
{
setServiceDescription("Qa Spider");
setServiceFlags(QtServiceBase::CanBeSuspended);
}
~QAService();
protected:
void start() { receiver.start(); }
void pause() { }
void resume() { }
private:
Receiver receiver;
};
main.cpp:
int main(int argc, char *argv[])
{
#if !defined(Q_WS_WIN)
// QtService stores service settings in SystemScope, which normally require root privileges.
// To allow testing this example as non-root, we change the directory of the SystemScope settings file.
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath());
#endif
QAService service(argc, argv);
return service.exec();
}
from qamqp.
Fixed. I use static build library QAmqpClient
from qamqp.
Related Issues (20)
- Trying to publish a message inside the 'connected' signal fails on reconnect. HOT 9
- ChannelNumber doesn't work HOT 1
- What license is this released under? HOT 3
- Tagged Versions HOT 2
- The timestamp in AMQP 0-9-1 should be in seconds other than miliseconds HOT 1
- Binding a queue to a headers exchange HOT 2
- Problems with the worker example HOT 8
- "x-expires" argument for queue's HOT 9
- Hostname resolution HOT 1
- Mass-publishing messages results in QAbstractSocket::UnconnectedState HOT 5
- Please expose the queue message count when queue was declared HOT 3
- Exchange list HOT 1
- Message rejecting doesn't work HOT 2
- Unable to get the default exchange
- Is this project DEAD ?
- Build under latest Ubuntu/Qt has a problem with include_next <stdlib.h> HOT 1
- Empty virtualhost deduced from uri
- Qt 6 support HOT 10
- what is the qamqpd lib file? The document coming soon! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qamqp.