activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Archie Cowan" <archie.co...@gmail.com>
Subject Re: Stomp to REST missing message body using examples
Date Sun, 06 Jan 2008 21:29:57 GMT
I'm a little closer now...

After reading that the message type is toggled on whether or not the
content-length header is included,
http://activemq.apache.org/stomp.html, I dug in to the stomp gem and
found that it is hard coded to always send the content-length header.

    def _transmit(s, command, headers={}, body='')
      @transmit_semaphore.synchronize do
        s.puts command
        headers.each {|k,v| s.puts "#{k}:#{v}" }
        s.puts "content-length: #{body.length}"
        s.puts "content-type: text/plain; charset=UTF-8"
        s.puts
        s.write body
        s.write "\0"
      end

After removing the content-length header, it seems to work as
expected. Would the right way to implement this be to use camel to
convert the message type for messages I want to consume over the web?
Or for this specific case would it be appropriate to implement a case
in MessageListenerServlet to handle BytesMessages?



On Jan 6, 2008 3:08 PM, Archie Cowan <archie.cowan@gmail.com> wrote:
> Hello,
>
> Using the latest AMQ 5.0.0 release and the ruby stomp-1.0.5 gem, I'm
> trying to send some messages via the example catstomp.rb script and
> receive the messages using the example javascript from
> http://activemq.apache.org/ajax.html. However, it doesn't appear that
> the message body is making it to the messages received on the
> javascript side.
>
> I send some messages like this to send the time every 5 seconds to the topic:
> while [ true ] ; do date ; sleep 5 ; done | ruby catstomp.rb
>
> Here's my javascript... pretty much copy and paste from the example:
>
> var myHandler = {
>   rcvMessage: function(message) {
>     alert("received "+message);
>   }
> };
> amq.addListener('web','topic://stompcat',myHandler.rcvMessage);
>
> Using firebug to examine the http response from amq, all I ever
> receive is a message with an empty body:
>
> <ajax-response>
> <response id='web' destination='topic://stompcat' ></response>
> </ajax-response>
>
> When I run the stompcat.rb script, I receive the message body:
>
> $ ruby stompcat.rb
> Connecting to stomp://localhost:61613 as
> Getting output from /topic/stompcat
> Sun Jan  6 14:50:07 EST 2008
> Sun Jan  6 14:50:12 EST 2008
> Sun Jan  6 14:50:17 EST 2008
> Sun Jan  6 14:50:22 EST 2008
> Sun Jan  6 14:50:27 EST 2008
>
> If I go to the topic in the activemq admin tool,
> http://localhost:8161/admin/topics.jsp, and send a message to the
> stompcat topic, I receive the message body in the javascript consumer
> as well as the stompcat.rb script.
>
> <ajax-response>
> <response id='web' destination='topic://stompcat' >Enter some text
> here for the message body...</response>
> </ajax-response>
>
> Is this supposed to work? It seems like there is something missing
> when sending from stomp and trying to receive via javascript. Any help
> would be most appreciated!
>
> Regards,
>
> Archie
>

Mime
View raw message