Updated Ruby STOMP client

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Updated Ruby STOMP client

robottaway
I am working with ActiveMQ a lot. I am using STOMP Ruby client to send messages into a queue. Those messages are consumed by a Windows service that is using an AMQ implementation of NMS. The consumer feeds the messages into a piece  of legacy software.

So anyway... I needed to send messages to AMQ from the Ruby client. The messages had to be marshalled into AMQ as JMS TextMessages. AMQ is marshalling all messages that have a 'content-length' STOMP header as JMS BinaryMessage's. Brians's STOMP client automatically would add this header. I edited Brian's Ruby client to contain a method called 'sendTextMessage' which will send a message to AMQ which then properly marshalls to JMS TextMessage. Here is the signature:stompHacked.rb

        # Send message to destination (marshalled as JMS TextMessage in ActiveMQ)
        #
        #
        def sendTextMessage(destination, message, headers={})
                headers[:destination] = destination
                transmit "SEND", headers, message
        end
       
If you want to call this message and input a 'content-length' header you could. The message would then be marshalled into AMQ as a JMS BinaryMessage :) Would it make more sense to just remove the code in the current client that sets the 'content-length' header in the _transmit method? The user would then be required to set this if they need it. Is there are reason behind always having this header set in the current client code?

I am attaching the hacked client code.