mbroadst / qamqp

AMQP 0.9.1 implementation for Qt
Other
151 stars 127 forks source link

Unable to get the default exchange #69

Closed DKMudrechenko closed 7 years ago

DKMudrechenko commented 7 years ago

I am trying to use the qamqp with RabbitMQ broker to establish communication between two applications - let's call them a client (Windows UWP app ) and a server (Qt app). So far I am able to pass a message from the client to the server using a default exchange and the server successfully gets the message.

incomingQueue = amqpClient->createQueue(this->incomingQueueName);
connect(incomingQueue, SIGNAL(declared()), this, SLOT(handleIncomingQueueDeclared()));
connect(incomingQueue, SIGNAL(qosDefined()), this, SLOT(handleIncomingQosDefined()));
connect(incomingQueue, SIGNAL(messageReceived()), this, SLOT(handleIncomingMessageReceived()));
incomingQueue->declare(QAmqpQueue::Durable);

However when I try to send a message from the server to the client, I am unable to get the default exchange:

amqpExchange = amqpClient->createExchange(""); // also tried createExchange() and createExchange("amq.default")
connect(amqpExchange, SIGNAL(declared()), this, SLOT(handleExchangeDeclared()));
connect(amqpExchange, SIGNAL(error(QAMQP::Error)), this, SLOT(handleQAMQPError(QAMQP::Error)));
amqpExchange->declare();

I am sending a message with:

QString message = "Hello world";
amqpExchange->publish(message, this->outgoingQueueName);

So not handleExchangeDeclared nor handleQAMQPError get triggered, however if I try to create an exchange with any other name like "new_queue" everything works as expected and messages are sent. I could just create a new exchange and call it good, however the client uses AMQP 1.0 and exchange is no longer a thing, the client uses the following code to listen for incoming messages:

this._amqpReceiver = new ReceiverLink(_amqpSession, "receiver-link", "q1");
_amqpReceiver.Start(10, async (r, m) =>
{
// I do stuff here
});

The RabbitMQ management portal says that both client and server are connected to the broker, both queues are created. However no messages come from the server. Am I doing something wrong here?