Brian's Waste of Time

Wed, 15 Nov 2006

JRuby Rocks

So, trying to reproduce a timing issue in ActiveMQ failover (which Hiram seems to have fixed in the recent 4.0.2 release, thank you!) I was able to whip various clients together super-quick:

#!/usr/bin/env jruby
require 'java'

module AMQFailoverTest
  include_package "org.apache.activemq"
  include_class "javax.jms.Session"

  b = "failover://(tcp://golem:35000,tcp://golem:35001)"
  factory = ActiveMQConnectionFactory.new b
  connection = factory.createConnection();
  session = connection.createSession(false, Session::AUTO_ACKNOWLEDGE)
  producer = session.createProducer(session.createTopic("test"))

  loop do
    producer.send(session.createTextMessage("this is only a test"))
  end
end

Thank you, JRuby folks! :-)

0 writebacks [/src/java] permanent link