Question

I'm using the ruby stomp gem to send messages to ActiveMQ. The data is being stored in Base64 encoded form, rather than as text, which is messing with my ability to use XPath selectors!

I've confirmed that using the 'send' functionality within jetty I can send non-Base64 encoded text to the same queue.

Any suggestions as to how to stop this from happening?


My test code:

require 'stomp'

stomp = { 
    :hosts => [{:host => 'localhost', :port => 61613}]
}

client = Stomp::Client.new(stomp)

queue = "/queue/test"
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<test>xml</test>"

client.publish(queue,xml,{
    :'content-type' => 'application/xml',
    :persistent     => true
})

I can then visit the ActiveMQ demos to see what's actually being stored:

 http://127.0.0.1:8161/demo/queueBrowse/test?view=xml

Output:

<messages queue="queue://test">
    <!-- snip -->
        <content>
            <data>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8+Cjx0ZXN0PnhtbDwvdGVzdD4A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAA=</data>
            <offset>0</offset>
            <length>56</length>
        </content>
    <!-- snip -->
</messages>
Was it helpful?

Solution

I've solved my own issue - here's a breakdown of why it was occurring.

ActiveMQ assumes that any incoming STOMP message with a content-length header is a ByteMessage and any without that header is a TextMessage (reference material).

Ruby's stomp gem tries to take account of this, but the header encoding method they've implemented breaks their own tests for a custom header: :suppress_content_length, which does what it says on the tin.

I've forked & modified their code to fix this - see my stomp repo - which hopefully they'll fold in soon enough.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top