[rabbitmq-discuss] SimpleAmqpClient speed?

Eric J. Holtman eric at holtmans.com
Thu Mar 8 13:15:32 GMT 2012


I've finally gotten everything working inside my
project (Thanks, Alan!).

I'm trying a small test now where I have one producer
and one consumer on a queue.  Running in Release mode
C++ (no debugging), I seem to top out around 3,700
messages/second.

Is that about what I should expect, or am I doing
something wrong?  I thought it should be higher.

I can believe (but have not yet profiled it) that I'm
losing throughput because of all the std::strings and
shared_ptrs.  If that's the case, I think that's just
the price I will have to pay for C++, unless I want
to drop down to using the underlying rabbitmq_c library.



Here's the guts of the producer:

	using namespace AmqpClient;
	Channel::ptr_t channel;
	channel = Channel::Create();

	channel->DeclareQueue("BasicReturnTestQueue", false, false, false, true);

	const std::string constant ("foo");
	try	{
		for (int i = 0; i < nmsgs; ++i) {
			BasicMessage::ptr_t the_message = BasicMessage::Create(constant);
			channel->BasicPublish("", "BasicReturnTestQueue", the_message, true,
false);
		}
		BasicMessage::ptr_t the_message = BasicMessage::Create("quit");
		channel->BasicPublish("", "BasicReturnTestQueue", the_message, true,
false);
	}
	catch (MessageReturnedException& e) {
		std::cout << "Message got returned: " << e.what();
		std::cout << "\nMessage body: " << e.message()->Body();
	}


And here's the consumer:

	using namespace AmqpClient;
	Channel::ptr_t channel;
	channel = Channel::Create();

	channel->DeclareQueue("BasicReturnTestQueue", false, false, false, true);
	channel->BasicConsume("BasicReturnTestQueue", "consumer_tag1", true,
true, true, 10);


	try {
		while (1) {
			Envelope::ptr_t env;
			if (channel->BasicConsumeMessage("consumer_tag1", env, 0)) {
				std::string msg = env->Message ()->Body ();
				if (msg == "quit") {
					return;
				}
			}
		}
	}
	catch (MessageReturnedException& e)
	{
		std::cout << "Message got returned: " << e.what();
		std::cout << "\nMessage body: " << e.message()->Body();
	}



More information about the rabbitmq-discuss mailing list