dan
unread,Feb 16, 2009, 1:05:23 PM2/16/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AMQP
Hi,
I am trying to use amqp in mod_ruby to place a database lookup into a
queue so that one of a pool of servers can reply. I have just a simple
no-op case and after the first turn (and a successful 1st reply)
apache's IO configuration is left in an unusable state so that all
subsequent hits to a particular worker just close the socket without
any data being written. Oddly enough, the error_log shows that the
request has come and the AMQP round trip was successful, but apache is
unable to write to the anticipated file descriptor that it allocated.
I think it is the result of the stop sequence at the end of the first
hit that does it.
This is my mod_ruby program:
require 'mq'
AMQP.logging=true
require 'singleton'
class AmqpTest
include Singleton
def handler apr
apr.status=::Apache::HTTP_OK
apr.content_type="text/plain"
apr.send_http_header
apr.write("reply:\n")
r=nil
AMQP.start {
amq=MQ.new
ns=0
pool=amq.queue('pool')
rqname='reply-'+MQ.id
reply=amq.queue(rqname, :auto_delete=>true)
$stderr.puts "sending" + tt=(Time.now.to_s)
$stderr.puts("5")
pool.publish(rqname + "|"+ tt)
reply.subscribe {|headers,body|
r="got [#{headers.inspect}] #{body}"
$stderr.puts "got [#{headers.inspect}] #{body}"
AMQP.stop { EM.stop }
}
}
apr.write(r)
apr.write("\n")
::Apache::OK
end
end
the end of an strace of a successful round trip is:
writev(9, [{"HTTP/1.1 200 OK\r\nDate: Mon, 16 F"..., 206}, {"17ac\r
\n", 6}, {"reply:\n[\"connected\"]\n\n[\"receive\""..., 6060}, {"\r
\n", 2}], 4) = 6274
writev(9, [{"0\r\n\r\n", 5}], 1) = 5
read(9, 0x16545098, 8000) = -1 EAGAIN (Resource
temporarily unavailable)
write(8, "10.100.1.79 - - [16/Feb/2009:12:"..., 71) = 71
poll([{fd=9, events=POLLIN, revents=POLLIN}], 1, 5000) = 1
read(9, "", 8000) = 0
gettimeofday({1234807160, 342188}, NULL) = 0
shutdown(9, 1 /* send */) = 0
poll([{fd=9, events=POLLIN, revents=POLLIN|POLLHUP}], 1, 2000) = 1
read(9, "", 512) = 0
close(9) = 0
And this is a bad one:
writev(0, [{"HTTP/1.1 200 OK\r\nDate: Mon, 16 F"..., 206}, {"17ac\r
\n", 6}, {"reply:\n[\"connected\"]\n\n[\"receive\""..., 6060}, {"\r
\n", 2}], 4) = -1 EBADF (Bad file descriptor)
writev(0, [{"0\r\n\r\n", 5}], 1) = -1 EBADF (Bad file
descriptor)
read(0, 0x166e7c48, 8000) = -1 EBADF (Bad file
descriptor)
write(8, "10.100.1.79 - - [16/Feb/2009:13:"..., 71) = 71
close(0) = -1 EBADF (Bad file
descriptor)