diff --git a/src/AMQPQueue.cpp b/src/AMQPQueue.cpp index 05362c3..15069d0 100644 --- a/src/AMQPQueue.cpp +++ b/src/AMQPQueue.cpp @@ -53,8 +53,6 @@ void AMQPQueue::Declare(string name, short parms) { } void AMQPQueue::sendDeclareCommand() { - if (!name.size()) - throw AMQPException("the queue must to have the name"); amqp_bytes_t queue_name = amqp_cstring_bytes(name.c_str()); @@ -106,6 +104,9 @@ void AMQPQueue::sendDeclareCommand() { } else if (res.reply.id == AMQP_QUEUE_DECLARE_OK_METHOD) { amqp_queue_declare_ok_t* data = (amqp_queue_declare_ok_t*) res.reply.decoded; count = data->message_count; + + if (name.empty()) + name = (const char*)data->queue.bytes; // Use the name generated by the RabbitMQ server } else { sprintf( error_message, "error the Declare command receive method=%d", res.reply.id); throw AMQPException(error_message);