-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QAmqpClient not work with QtService #55
Comments
@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. |
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();
} |
Fixed. I use static build library QAmqpClient |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now QAmqpClient not work with QtService.
For connect I use code from tutorials/helloworld/receive:
Please, help me
The text was updated successfully, but these errors were encountered: