[rabbitmq-discuss] RabbitMQ, Gretty, and Channel question

Burt Prior burtprior at comcast.net
Wed Sep 21 22:01:17 BST 2011


Hi there,

I came across an interesting issue that I was hoping someone could help me with.
I think its related to Channel thread-safety.  Here's the issue.

I want to create an lightweight web service endpoint using Gretty that sends (json) messages to rabbitmq.
It works, but when i benchmark it with 'ab -n 1000 -c 100 http://x.x.x.x/' there are 1003 messages in the queue!

Gretty relies on Netty (http://www.jboss.org/netty) which is an asynchronous event-driven framework that uses NIO.

I've included the (working, no error) Gretty code below.  Could I ask for your insight as to why there are more messages in the queue than the producer (ab) sent?

Thanks for your time,
Burt Prior

server.groovy:

import org.mbte.gretty.httpserver.*

//
// server.groovy
// web service endpoint for activity requests
// 9/15/11: bprior
//
// $ groovy server.groovy
//
// then try benchmark:
// $ ab -n 1000 -c 100 http://192.168.1.129:8080/
//

import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;

@GrabResolver(name='gretty', root='http://groovypp.artifactoryonline.com/groovypp/libs-releases-local')
@Grab('org.mbte.groovypp:gretty:0.4.279')

@Grab(group='com.rabbitmq', module='amqp-client', version='2.6.1')

ConnectionFactory factory = new ConnectionFactory();
factory.setHost("dallas");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.queueDeclare("hello", false, false, false, null);

GrettyServer server = []
server.groovy = [
 localAddress: new InetSocketAddress("dallas", 8080),
   defaultHandler: {
  response.redirect "/"
 },
   "/:name": {
   get {
   String message = "{msg: {actorId:\"bprior\",actorType:\"PERSON\"}}";
   
   channel.basicPublish("", "hello", null, message.getBytes());
   //response.text = "Hello ${request.parameters['name']}"
  }
 }
]
server.start()
println "factory:"+factory
println "server started..."





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110921/1a303f30/attachment.htm>


More information about the rabbitmq-discuss mailing list