# Implementing publish subscribe in ruby

**URL:** <https://www.ruby-forum.com/t/implementing-publish-subscribe-in-ruby/59052>\
**Category:** Ruby\
**Created:** [April 28, 2006, 7:43am UTC](https://www.ruby-forum.com/t/implementing-publish-subscribe-in-ruby/59052 "2006-04-28T07:43:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bujji\_choudhary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cdc98d/32.png) [@bujji\_choudhary](https://www.ruby-forum.com/u/bujji_choudhary)\
**Post date:** [April 28, 2006, 7:43am UTC](https://www.ruby-forum.com/t/implementing-publish-subscribe-in-ruby/59052/1 "2006-04-28T07:43:37Z")

</div>

Hi all…  
I want to implement publish subscribe pattern for small application  
like “stock market” or " reservation of trains". Can any body tell me  
where to start. I am new to ruby.

If anybody is having any code for that please send me. I’ll be  
greatful.

```
                  Thanks in advance....

                                   LENIN.
```

---

<div class="post-metadata">

**Author:** ![bujji\_choudhary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cdc98d/32.png) [@bujji\_choudhary](https://www.ruby-forum.com/u/bujji_choudhary)\
**Post date:** [April 28, 2006, 8:56am UTC](https://www.ruby-forum.com/t/implementing-publish-subscribe-in-ruby/59052/2 "2006-04-28T08:56:19Z")

</div>

On 4/28/06, bujji choudhary [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi all…  
> I want to implement publish subscribe pattern for small application like “stock market” or " reservation of trains". Can any body tell me where to start. I am new to ruby.
> 
> If anybody is having any code for that please send me. I’ll be greatful.

If what you’re looking for is a simple non-distributed observer  
pattern, Ruby includes one in the standard library. Check [1] for the  
documentation. The example usage on that page is actually a simple  
stock market!

Otherwise, if you’re looking for a distributed solution, check DRb [2]  
(Distributed Ruby) and Rinda [3], Ruby’s implementation of the  
tuplespace paradigm. It’s not classical publish/subscribe but can be  
used to do the same kind of things.

[1]  
[http://www.ruby-doc.org/stdlib/libdoc/observer/rdoc/files/observer\_rb.html](http://www.ruby-doc.org/stdlib/libdoc/observer/rdoc/files/observer_rb.html)  
[2] [http://www.ruby-doc.org/stdlib/libdoc/drb/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/drb/rdoc/index.html)  
[3] [http://www.ruby-doc.org/stdlib/libdoc/rinda/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/rinda/rdoc/index.html)
