Search code examples
rubyactivemq-classicstomp

using ruby and stomp to write messages to ActiveMQ


I'm using stomp to write messages to ActiveMQ from Ruby. I'm following example at http://calliopesounds.blogspot.com/2009/07/working-ruby-stomp-example.html

But i'm getting the below error, not sure what is wrong

/Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:462:in `write': Invalid argument (Errno::EINVAL)
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:462:in `puts'
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:462:in `_transmit'
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:462:in `each'
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:462:in `_transmit'
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:445:in `synchronize'
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:445:in `_transmit'
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:427:in `transmit'
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/connection.rb:267:in `publish'
    from /Library/Ruby/Gems/1.8/gems/stomp-1.1.10/lib/stomp/client.rb:200:in `publish'
    from utils.rb:10

here is the script

require 'rubygems'
require 'stomp'

queue = "/queue/msg.in"

puts "Producer for queue #{queue}"

client = Stomp::Client.open "stomp://localhost:61616"
puts client
client.publish queue, "hello!"
client.close

Solution

  • This might not be your exact problem, but since the code chokes on the send it could be something similar.

    By default localhost:61616 is where AMQ broker listens for openwire connections. Did you change the broker xml config to use stomp on that port? The config should have an entry like:

    <transportConnectors>
       <transportConnector name="stomp" uri="stomp://localhost:61613"/>
    </transportConnectors>