Computing Magazine

How to Use ActiveMQ in Rails App

Posted on the 18 November 2014 by Abhishek Somani @somaniabhi
Active MQ is one of the most popular messaging server . In this post we will list out the steps on how to use it in rails application. Installation ActiveMQ procedure for Ubuntu 14.04Download ActiveMQ 5.4.2 from http://activemq.apache.org/download.htmlor you can install it from console by writing following command .

sudo apt-get install activemq
Now start the server by writing following command :

$ ./activemq start
Now , for connecting activeMQ server , we can use Stomp Gem . So for sending message , open IRB prompt and write following command :

$ irb req1.9.3-p362 :001 > require "stomp"=> true
1.9.3-p362 :002 > client = Stomp::Client.new("aDMIN", "admin", "localhost", 61613)
You might get error like this :

Errno::ECONNREFUSED: Connection refused - connect(2)
from /home/usermac44/.rvm/gems/ruby-1.9.3-p362/gems/stomp-1.3.3/lib/connection/netio.rb:203:in `initialize'
We have to configure stomp protocol on our activemq server like this : Add the following line to the configuration file:

<transportConnectors>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600"/>
</transportConnectors>
Now restart activemq. and send the message again . It will work now . You can see the active mq console at http://localhost:8161/admin . Thanks to santosh for writing this post . How to Use ActiveMQ in Rails App

Back to Featured Articles on Logo Paperblog

Paperblog Hot Topics

Magazines