I'm not seeing the expected throughput on the consume side of things using the Java client API and looking for some suggestions. The way I've set up my tests I create N=25 channels/queue consumers for a single queue (according to the java api docs you can't have more than one thread on a given channel at once) and then I have 50 threads that fill up the queue (publish throughput is fine) and then another 50 threads which pull from the queue. I synchronize on the channels and each thread uses round robin to to select a channel and queue consumer pair and uses that to do the consume and ack. But even after some twiddling I am not able to get beyond 50 reads per sec which is less than 10x what I am seeing on the publish side. Below is what the key code looks like. Any suggestions for what may be causing the slowness?<br>
<br>thanks,<br>Scott<br><br>Here is the consume code looks like:<br><br> Integer channelNum = pickRandomChannel();<br> Channel channel = getChannel( channelNum );<br> QueueingConsumer consumer = getConsumer( channelNum );<br>
synchronized (getChannel( channelNum )) {<br> try {<br> channel.basicConsume( getQueueName(), noAck, consumer ); //noAck = false here<br> } catch (IOException e) {<br> logger.warn( "Exception when consuming message from queue: " + getQueueName(), e );<br>
}<br> try {<br> QueueingConsumer.Delivery delivery = consumer.nextDelivery( this.defaultTimeout );<br> if (delivery == null) {<br> return null;<br> }<br> return delivery.getBody()<br>
} catch (InterruptedException ie) {<br> logger.warn( "Interruped exception on next delivery", ie );<br> return null;<br> }<br> }<br>