查看整个队列的描写--POC

This commit is contained in:
JesseQu 2025-07-31 17:17:40 +08:00
parent 0300258b93
commit 2db9be9b92
3 changed files with 34 additions and 7 deletions

View File

@ -24,10 +24,10 @@
#define AMQP_SSL_SCHEME "amqps"
#define AMQP_PORT 5672
#define AMQP_SSL_PORT 5671
#define AMQP_HOST "localhost"
#define AMQP_HOST "192.168.46.100"
#define AMQP_VHOST "/"
#define AMQP_LOGIN "guest"
#define AMQP_PSWD "guest"
#define AMQP_LOGIN "ecl3000"
#define AMQP_PSWD "ecl3000"
#define AMQP_FRAME_MAX 131072
#define AMQP_FRAME_MIN_SIZE 4096

View File

@ -33,8 +33,22 @@ private Q_SLOTS:
return;
connect(queue, SIGNAL(messageReceived()), this, SLOT(messageReceived()));
queue->consume(QAmqpQueue::coNoAck);
// queue->consume(QAmqpQueue::coNoAck);
// queue->consume(QAmqpQueue::coNoLocal);
qint32 sizeQueue = queue->messageCount();
while (sizeQueue--) {
queue->get(false);
}
qDebug() << " [*] Waiting for messages. To exit press CTRL+C";
queue->ack(3, false); // Acknowledgement the 3rd message.
queue->reopen();
// m_client.disconnectFromHost();
}
void messageReceived() {
@ -43,7 +57,11 @@ private Q_SLOTS:
return;
QAmqpMessage message = queue->dequeue();
qDebug() << " [x] Received " << message.payload();
qDebug() << " [x] Received in" << message.payload();
int input=0;
// std::scanf("%d", &input);
qDebug() << " [x] Received out, " << message.deliveryTag() << " | " << message.payload() << " , input = " << input;
}
private:
@ -53,6 +71,7 @@ private:
int main(int argc, char **argv)
{
qDebug() << " Recieve starts ... ";
QCoreApplication app(argc, argv);
Receiver receiver;
receiver.start();

View File

@ -31,8 +31,16 @@ private Q_SLOTS:
if (!queue)
return;
QAmqpExchange *defaultExchange = m_client.createExchange();
defaultExchange->publish("Hello World!", "hello");
qDebug() << " [x] Sent 'Hello World!'";
defaultExchange->publish("Hello World! A", "hello");
qDebug() << " [x] Sent 'Hello World! A'";
defaultExchange->publish("Hello World! B", "hello");
qDebug() << " [x] Sent 'Hello World! B'";
defaultExchange->publish("Hello World! C", "hello");
qDebug() << " [x] Sent 'Hello World! C'";
defaultExchange->publish("Hello World! D", "hello");
qDebug() << " [x] Sent 'Hello World! D'";
defaultExchange->publish("Hello World! E", "hello");
qDebug() << " [x] Sent 'Hello World! E'";
m_client.disconnectFromHost();
}