# Connecting MQ from Rails?

**URL:** <https://www.ruby-forum.com/t/connecting-mq-from-rails/64227>\
**Category:** Rails\
**Created:** [June 23, 2006, 7:24am UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227 "2006-06-23T07:24:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 23, 2006, 7:24am UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/1 "2006-06-23T07:24:31Z")

</div>

Hi all,

I want to Connect to IBM MQ from Rails/Ruby, can it be done? and get the  
messages from the Queue, then i want to use this message in ruby/rails.

Is there a direct way of doing the above job?? If so any packages are  
available?

If there is not a way currently, and any thoughts of how we can do the  
above job indirectly through some other means or round about ways or  
workarounds can be thought of ?. Appreciate your comments.

Thank You,  
Dinesh

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 25, 2006, 2:48am UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/2 "2006-06-25T02:48:33Z")

</div>

In the past, I’ve done this via COM from a Windows PC running Ruby.  
Works fine, and the throughput is surprisingly good.

You can find details of how to access MQ via COM from IBM’s site -  
it’s in the downloadable documentation set, and wasn’t hard to track  
down if my memory’s correct.

Details of how to use COM from Ruby on a Windows PC are in the  
Programming Ruby book.

Regards

Dave M.

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 25, 2006, 1:40pm UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/3 "2006-06-25T13:40:02Z")

</div>

Another alternative would be to write an extension to make use of the C  
API  
directly (if you are not on windows). Seeing as MQ has about 70% market  
share, I think this is a project folks might be willing to help with.

-Brian

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 27, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/4 "2006-06-27T14:13:20Z")

</div>

Hi Brian,

Thanks for the reply. Ya since our production box is going to be on a  
AIX box, i think i cannot go for COM interface and going with C  
extension would be better we believe.

Do you have any docs / samples which access the MQI Interface using the  
C extension from Ruby? If you have it can you pl let me know the  
pointers pl?

Thank You  
Dinesh

Brian McCallister wrote:

> Another alternative would be to write an extension to make use of the C  
> API  
> directly (if you are not on windows). Seeing as MQ has about 70% market  
> share, I think this is a project folks might be willing to help with.
> 
> -Brian

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 28, 2006, 6:52am UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/5 "2006-06-28T06:52:56Z")

</div>

Thanks Bryan for the replies.

So if i’m correct, what you meant is having an option to "Re-direct all  
the messages from WebSphere MQ to ActiveMQ as and when it arrives ", and  
then from ruby use STOMP to get the messages?

Thank You  
Dinesh

Bryan L. wrote:

> On Jun 23, 2006, at 1:24 AM, Dinesh U. wrote:
> 
> > If there is not a way currently, and any thoughts of how we can do the  
> > above job indirectly through some other means or round about ways or  
> > workarounds can be thought of ?. Appreciate your comments.
> 
> You could use ActiveMQ as a bridge. ActiveMQ supports the STOMP  
> protocol which has ruby bindings.

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 27, 2006, 4:47pm UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/6 "2006-06-27T16:47:59Z")

</div>

On Jun 23, 2006, at 1:24 AM, Dinesh U. wrote:

> If there is not a way currently, and any thoughts of how we can do the  
> above job indirectly through some other means or round about ways or  
> workarounds can be thought of ?. Appreciate your comments.

You could use ActiveMQ as a bridge. ActiveMQ supports the STOMP  
protocol which has ruby bindings.

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 28, 2006, 8:21am UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/7 "2006-06-28T08:21:15Z")

</div>

This

[http://rubyforge.org/projects/yajb/](http://rubyforge.org/projects/yajb/)

is pure ruby, and if you are familar with the MQ java api it may be the  
way  
to go.

I think it uses XML-RPC, which maybe a limiter to throughput, although  
if  
you are driving things from a webapp this may not be a problem.

cheers  
lyndon

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 28, 2006, 11:41am UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/8 "2006-06-28T11:41:07Z")

</div>

Hi Lyndon,

When i hit the link [http://rubyforge.org/projects/yajb/](http://rubyforge.org/projects/yajb/), it says  
“This Project Has Not Released Any Files” and the status says “Beta”, so  
it is not published to rubyforge site yet??

Thanks…  
Dinesh

Lyndon S. wrote:

> This
> 
> [http://rubyforge.org/projects/yajb/](http://rubyforge.org/projects/yajb/)
> 
> is pure ruby, and if you are familar with the MQ java api it may be the  
> way  
> to go.
> 
> I think it uses XML-RPC, which maybe a limiter to throughput, although  
> if  
> you are driving things from a webapp this may not be a problem.
> 
> cheers  
> lyndon

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 29, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/9 "2006-06-29T19:04:37Z")

</div>

An alternative to YAJB (beta) might be JRuby (beta) which we’ve been  
working  
very hard on. Performance is still sub-par, but you could very easily  
wrap  
JMS to provide access to MQ. Another option frequently suggested might  
be to  
implement a web service, but you’re adding a lot of overhead there.

If you’d be interested in exploring the JRuby angle, feel free to email  
me  
or join the JRuby mailing lists at [www.jruby.org](http://www.jruby.org).

---

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 28, 2006, 12:29pm UTC](https://www.ruby-forum.com/t/connecting-mq-from-rails/64227/10 "2006-06-28T12:29:48Z")

</div>

I’ve used this to drive some XSLFO stuff (using Apache FOP) and can say  
it  
works well (if you can get past the somewhat disturbing site of  
Java-esque  
code in your Ruby programs).

You can get to the actual download from the authors site:  
[Software Error](http://www.cmt.phys.kyushu-u.ac.jp/~M.Sakurai/cgi-bin/fw/wiki.cgi?page=YAJB)(which  
is linked from the rubyforge site as “Project Home Page”).

As to speed it uses a binary protocol by default in the newest version  
so it  
should be faster than the XML-RPC protocol that Lyndon mentions  
(although  
it’s not blisteringly fast either way).

Cheers

Muz
