Jruby and activemq/JMS

anyone have any experience using Jruby with either JMS or ActiveMQ?
Looking
to build a messaging architecture and there are a few interesting
articles
about using the JMS Client consumer right in the jruby code.
Just seeing if anyone has any feedback or experience dealing with this.
we
are hitting a lot of walls with synchronous calls to external sources
and
need to move to a more async model. Our app is currently rails inside
tomcat as a .war so we were thinking of running activemq standalone
(outside
of Tomcat) and then just building a JMS producer client inside the rails
app
controller

Any info would be great.

Thanks
Adam

Calling JMS from JRuby is fairly straightforward. I’ve used both
OpenJMS and ActiveMQ quite successfully. ActiveMQ also gives you the
option of using Stomp instead of JMS. There’s a decent ruby stomp
client out there that works fine with JRuby.

On Jul 21, 2008, at 10:45 PM, AD wrote:

building a JMS producer client inside the rails app controller

Any info would be great.

Thanks
Adam


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Mon, Jul 21, 2008 at 9:45 PM, AD [email protected] wrote:

anyone have any experience using Jruby with either JMS or ActiveMQ? Looking
to build a messaging architecture and there are a few interesting articles
about using the JMS Client consumer right in the jruby code.
Just seeing if anyone has any feedback or experience dealing with this. we
are hitting a lot of walls with synchronous calls to external sources and
need to move to a more async model. Our app is currently rails inside
tomcat as a .war so we were thinking of running activemq standalone (outside
of Tomcat) and then just building a JMS producer client inside the rails app
controller
Any info would be great.

I’m starting on some native JMS support in JRuby-Rack. The idea is
similar to ActiveMessaging that I want to be able to do asynchronous
messaging, but with the code living and running in the same webapp.
You can follow the code on my “jms” branch on github
(http://github.com/nicksieger/jruby-rack/commits/jms/) but be warned
that it’s not functional yet. I hope to find some time soon to work on
it again.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

i tried following the example but getting the following error:

consumer.rb:21:in const_missing': uninitialized constant MessageHandler::Session (NameError) from consumer.rb:21:inrun’
from consumer.rb:33

Any ideas?

Code is below:

require "java" require "activemq-all-5.1.0.jar"

include_class “org.apache.activemq.ActiveMQConnectionFactory”
include_class “org.apache.activemq.util.ByteSequence”
include_class “org.apache.activemq.command.ActiveMQBytesMessage”
include_class “javax.jms.MessageListener”

class MessageHandler
include javax.jms.MessageListener

def onMessage(serialized_message)
message_body =
serialized_messageed_message.get_content.get_data.inject("") { |body,
byte|
body << byte }
customer_payload = YAML.load(message_body)
puts customer_payload
end

def run
factory = ActiveMQConnectionFactory.new(“tcp://localhost:61616”)
connection = factory.create_connection();
session = connection.create_session(false,
Session::AUTO_ACKNOWLEDGE);
queue = session.create_queue(“test1-queue”);

consumer = session.create_consumer(queue);
consumer.set_message_listener(self);

connection.start();
puts "Listening..."

end
end

handler = MessageHandler.new
handler.run

i got it , was missing javax.jms.Session.

Adam

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs