Rails or Tomcat - which one to be used for backgorund task?

Hi,

I need advice on a decision that I have to make to decide whether I
should do background task in Rails or in Tomcat.

What I need to do is that a user of web app will create nnumber of text
messages which need to be sent to around 10,000+ users. Sms msg is
passed by the Ruby application to a http server running under Tomcat to
a java application that further passes the msg to sms gateway to be
deliverd to user.
I am planning to put msgs to be sent in a table in mysql by the ruby
application. Now I am not sure which is the reliable and better way to
send the msgs in the background - a background task in ruby or a
backgorund task in java. Also which is the best way to schedule and
start a background job in ruby/rails to handle such a large number of
records to be handled?

Thanks for the help in advance.

I dont think your challenge is where to run the background task as much as it is how to handle sending of large number of messages between systems. I would recommend you look at leveraging a messaging broker like ActiveMQ that will allow you to send messages asynchronously to a message queue that can then be picked up for processing by your java application with some JMS client code.

have a look here for some example code on writing a JMS client in JRuby that would allow you to put messages onto the queue

http://blog.dberg.org/2008/07/jms-jruby-producer-and-consumer.html. That is of course if you are using JRuby.

If you are using straight MRI ruby/rails then have a look at integrating ActiveMQ with Activemessaging using the STOMP Protocol.

http://code.google.com/p/activemessaging/wiki/ActiveMessaging

Adam