Hi,

Recently i worked on creating a queue in Active MQ and sending a message/xml to active mq using ruby I would like to share this..

1) For connecting to active mq need stomp gem.
2) Below is the command for installing the stomp gem. Go to the ruby folder and give the below command.

'gem install stomp'
3)Go to the below path of the active mq installed(remote or local)

C:\Program Files\apache-activemq-5.5.0\conf

4) Open activemq.xml file change the configutations as below. Enabled the connection for stomp protocol.

Before change

<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
</transportConnectors>

After Change:


<transportConnectors>
<!-- <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/> -->
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613"/>
</transportConnectors>

5) After doing the changes in the activemq.xml file save it and start the active mq by runing the activemq.bat file location in the below location.

C:\Program Files\apache-activemq-5.5.0\bin

6) Below is the code used for reading the xml and sending the xml to the active mq (by creating new queue).


require "rubygems"
require "stomp"
require 'rexml/document'

#reading the xml
file = File.new( "Order.xml" )//give the location of xml
order_xml = REXML:ocument.new file
puts(order_xml)
#connection to queue
client = Stomp::Client.open "stomp://ip:61613"
headers = {ersistent => 'false' , [img]/images/graemlins/tongue.gif[/img]riority => 0 , :suppress_content_length => true }
#sending the xml
client.publish('/queue/queue_name',order_xml,headers)


7) Execute the script (before executing make sure to have the xml in the specified location and the active mq is started.)

Note: use the url http://ip:8161/admin and make sure the active mq console is displayed.

8) Now open the url and select 'queues' option in the menu and select the created queues

9) The created queue(queue_name) should be displayed and on selecting the queue the xml that is pushed should be displayed in that queue.


Regards,
karri