You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by robottaway <ro...@musiciansfriend.com> on 2006/10/25 02:07:01 UTC

Ruby STOMP client - TextMessage

I am using the Ruby STOMP client. I would like the STOMP transport in AMQ to
convert incoming STOMP messages to TextMessage rather than ByteMessage. How
can I do this? I see lots of info on not setting a content-length header.
The Ruby STOMP client sets this header to the size of the message body
though, so the content-length header is always set :(

Okay I was writing the above when I decided to just try hacking the stomp.rb
file. I commented out the section where _transmit sets the content-length
header to the text's size. This worked like a charm! Is this okay to do
though?
-- 
View this message in context: http://www.nabble.com/Ruby-STOMP-client---TextMessage-tf2504913.html#a6983941
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Ruby STOMP client - TextMessage

Posted by Hiram Chirino <hi...@hiramchirino.com>.
On 10/25/06, robottaway <ro...@musiciansfriend.com> wrote:
>
>
> The change to Brian's Ruby client is done. You now can call either send
> (for
> JMS BinaryMessage) or sendTextMessage (for JMS TextMessage) on the client.
> These will map into the STOMP transport nicely. Reading either
> TextMessages
> or ByteMessages from the queue works as before my changes. I have only
> tested the client changes in AMQ 4.0.2 so far (see section below).
>
> Question: The sendTextMessage method will not include the header
> 'content-length'. Does this make the method non-functional with a true
> STOMP
> implementation? Asking this in another way, does STOMP always expect the
> 'content-length' header to be set? Or is this header strictly related to
> AMQ's transport implementation? The new sendTextMessage method will work
> great for the AMQ STOMP transport, but would it work with any properly
> implemented STOMP server?


I don't think it makes it ActiveMQ specific.  STOMP states that you can send
frames with a
content length or with out.  Your methods are allowing the stomp client to
choose which from to use.


TESTING:
> My test so far consisted of:
> One queue: foo.bar
>
> 2 x
> Setting a writer to constantly spam 20 binary messages per second to AMQ
> through the updated STOMP Ruby client
>
> 2 x
> Setting a producer to constantly spam 20 text messages per second to AMQ
> through the updated STOMP Ruby client
>
> One consumer which uses the STOMP Ruby client to consume all these
> messages!
> (I then added another consumer on the fly and things worked fine)
>
> The consumers and producers are running on a 3.0 GHz IBM PC, and AMQ 4.0.2
> is running on my MacBook.
>
> So far I have run through around 40k messages, or about 10k per producer.
> The consumer does not seem to have any troubles. I have jconsole running
> and
> it looks like every message produced has been consumed. Thats good enough
> for me right now.


Yay!

I also had my Windows service, which uses the NMS AMQ implementation :),
> come online and also subscribe to the foo.bar queue. This ran a bit and
> got
> text messages no problem (although exceptions are caught for the
> BinaryMessage).


Yeah.. NMS might need some work. :(

BTW:
> Where should I upload this code to? If what I mentioned above makes this
> client sorta AMQ specific then maybe it should exist on AMQ's site rather
> than STOMP?


Perhaps Brian can take your patch.. Brian, you on this list or what?  While
I would not mind having the stomp clients hosted at apache, I would rather
they get hosted at language specific sites like http://rubyforge.org/, and
CPAN, php.net, etc. etc.


--
> View this message in context:
> http://www.nabble.com/Ruby-STOMP-client---TextMessage-tf2504913.html#a6999015
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Re: Ruby STOMP client - TextMessage

Posted by robottaway <ro...@musiciansfriend.com>.
The change to Brian's Ruby client is done. You now can call either send (for
JMS BinaryMessage) or sendTextMessage (for JMS TextMessage) on the client.
These will map into the STOMP transport nicely. Reading either TextMessages
or ByteMessages from the queue works as before my changes. I have only
tested the client changes in AMQ 4.0.2 so far (see section below).

Question: The sendTextMessage method will not include the header
'content-length'. Does this make the method non-functional with a true STOMP
implementation? Asking this in another way, does STOMP always expect the
'content-length' header to be set? Or is this header strictly related to
AMQ's transport implementation? The new sendTextMessage method will work
great for the AMQ STOMP transport, but would it work with any properly
implemented STOMP server?

TESTING:
My test so far consisted of:
One queue: foo.bar

2 x
Setting a writer to constantly spam 20 binary messages per second to AMQ
through the updated STOMP Ruby client

2 x
Setting a producer to constantly spam 20 text messages per second to AMQ
through the updated STOMP Ruby client

One consumer which uses the STOMP Ruby client to consume all these messages!
(I then added another consumer on the fly and things worked fine)

The consumers and producers are running on a 3.0 GHz IBM PC, and AMQ 4.0.2
is running on my MacBook.

So far I have run through around 40k messages, or about 10k per producer.
The consumer does not seem to have any troubles. I have jconsole running and
it looks like every message produced has been consumed. Thats good enough
for me right now.

I also had my Windows service, which uses the NMS AMQ implementation :),
come online and also subscribe to the foo.bar queue. This ran a bit and got
text messages no problem (although exceptions are caught for the
BinaryMessage).

BTW:
Where should I upload this code to? If what I mentioned above makes this
client sorta AMQ specific then maybe it should exist on AMQ's site rather
than STOMP?
-- 
View this message in context: http://www.nabble.com/Ruby-STOMP-client---TextMessage-tf2504913.html#a6999015
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Ruby STOMP client - TextMessage

Posted by Hiram Chirino <hi...@hiramchirino.com>.
On 10/25/06, robottaway <ro...@musiciansfriend.com> wrote:
>
>
> Could I patch it up so that we have a 'sendTextMessage' method, and then
> the
> normal 'send' method (for binary)? This makes a little sense to me, in the
> case that someone wants to send a message consisting of text as a binary
> message.



This sounds ideal!

It looks like you guys are using the content-length header as the only
> indication of text vs. binary in the STOMP transport for AMQ. I've seen
> talk


Right.


> of setting up the transport object so that it would handle a 'type' header
> which would allow the user to have a content-length header but still
> marshall the message into the AMQ system as a text message. I believe this
> would be done using the header 'type' set to 'text'. If this is not what
> happens then I will submit the client so that others  can use it to submit
> TextMessage messages into AMQ from STOMP.


I think that what's going to happens is that the existing simplistic system
is going to remain as is.  I think STOMP will start evolving some extensions
that do more fancy mappings of STOMP frames to JMS messages.  And the STOMP
client will select which mapping strategy it expects to be used when it
connects. something like:


CONNECT
frame-translation: default

or

CONNECT
frame-translation: json

So one day we might develop a ruby client that uses the json translation and
the messages are encoded in JSON for example.  This could allow stomp
clients to receive Map messages too.


--
> View this message in context:
> http://www.nabble.com/Ruby-STOMP-client---TextMessage-tf2504913.html#a6994038
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Re: Ruby STOMP client - TextMessage

Posted by robottaway <ro...@musiciansfriend.com>.
Could I patch it up so that we have a 'sendTextMessage' method, and then the
normal 'send' method (for binary)? This makes a little sense to me, in the
case that someone wants to send a message consisting of text as a binary
message.

It looks like you guys are using the content-length header as the only
indication of text vs. binary in the STOMP transport for AMQ. I've seen talk
of setting up the transport object so that it would handle a 'type' header
which would allow the user to have a content-length header but still
marshall the message into the AMQ system as a text message. I believe this
would be done using the header 'type' set to 'text'. If this is not what
happens then I will submit the client so that others  can use it to submit
TextMessage messages into AMQ from STOMP.
-- 
View this message in context: http://www.nabble.com/Ruby-STOMP-client---TextMessage-tf2504913.html#a6994038
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Ruby STOMP client - TextMessage

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Hi,

Sounds valid.  Send us the patch.

On 10/24/06, robottaway <ro...@musiciansfriend.com> wrote:
>
>
> I am using the Ruby STOMP client. I would like the STOMP transport in AMQ
> to
> convert incoming STOMP messages to TextMessage rather than ByteMessage.
> How
> can I do this? I see lots of info on not setting a content-length header.
> The Ruby STOMP client sets this header to the size of the message body
> though, so the content-length header is always set :(
>
> Okay I was writing the above when I decided to just try hacking the
> stomp.rb
> file. I commented out the section where _transmit sets the content-length
> header to the text's size. This worked like a charm! Is this okay to do
> though?
> --
> View this message in context:
> http://www.nabble.com/Ruby-STOMP-client---TextMessage-tf2504913.html#a6983941
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com