# Re: Drb / ActiveRecord as Application Server for Qt/Ruby cli

**URL:** <https://www.ruby-forum.com/t/re-drb-activerecord-as-application-server-for-qt-ruby-cli/101414>\
**Category:** Ruby\
**Created:** [August 4, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/re-drb-activerecord-as-application-server-for-qt-ruby-cli/101414 "2006-08-04T19:21:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![philpraxis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/77aa72/32.png) [@philpraxis](https://www.ruby-forum.com/u/philpraxis)\
**Post date:** [August 4, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/re-drb-activerecord-as-application-server-for-qt-ruby-cli/101414/1 "2006-08-04T19:21:47Z")

</div>

Logan C. wrote:

> > - Distributed Ruby Server  
> > Is it safe and robust, anyway, on an intranet composed of a hundred  
> > across the network, why even have a server / client  
> > architecture? Just stick the AR code in the “Client” and let  
> > PostgreSQL worry about concurrency.

I prefer a 3-tier approach, with all the buisness logic on the server,  
just like you would do with J2EE. Centralisation of code is a good thing  
I think.

---

<div class="post-metadata">

**Author:** ![philpraxis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/77aa72/32.png) [@philpraxis](https://www.ruby-forum.com/u/philpraxis)\
**Post date:** [August 5, 2006, 4:57pm UTC](https://www.ruby-forum.com/t/re-drb-activerecord-as-application-server-for-qt-ruby-cli/101414/2 "2006-08-05T16:57:12Z")

</div>

On Aug 4, 2006, at 12:20 PM, Philippe L. wrote:

> I prefer a 3-tier approach, with all the buisness logic on the  
> server, just like you would do with J2EE. Centralisation of code is  
> a good thing I think.

You’re already using ActiveRecord…why not throw the rest of the  
Rails stack in and use REST, XML-RPC or SOAP?

---

<div class="post-metadata">

**Author:** ![philpraxis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/77aa72/32.png) [@philpraxis](https://www.ruby-forum.com/u/philpraxis)\
**Post date:** [August 5, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/re-drb-activerecord-as-application-server-for-qt-ruby-cli/101414/3 "2006-08-05T23:03:37Z")

</div>

Quoting A. Keys [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> On Aug 4, 2006, at 12:20 PM, Philippe L. wrote:
> 
> > I prefer a 3-tier approach, with all the buisness logic on the  
> > server, just like you would do with J2EE. Centralisation of code is  
> > a good thing I think.
> 
> You’re already using ActiveRecord…why not throw the rest of the Rails  
> stack in and use REST, XML-RPC or SOAP?

The problem with QtRuby and DRb, XML-RPC, EventMachine, etc is each  
one of them has its own event loop.

Once you call $qapp.exec in QtRuby, you application enters the Qt  
event loop and you cannot call anything outside that loop. The same  
goes for XMLRPC4R and the server.serve call: once you call  
myserver.serve, your application waits in an event loop, so you cannot  
run $qapp.exec because QtRuby does not work with Ruby threads. The  
only approach you can take to “fix” this is described here:  
[http://rubyforge.org/forum/message.php?msg\_id=3329](http://rubyforge.org/forum/message.php?msg_id=3329)

The explanation is here:  
[http://rubyforge.org/forum/message.php?msg\_id=3341](http://rubyforge.org/forum/message.php?msg_id=3341)

But you should realize this is more of an accident than a feature.

The best solution for this problem is to implement your own protocol  
using QtRuby. If your QtRuby application is actually a Korundum  
application, another approach would be to have two independent  
applications (the Korundum app and the XML-RPC/EventMachine/whatever  
listener) and have them communicate through DCOP. If your application  
is a QtRuby 4 one, you may use DBUS as well but take in account the  
Ruby-DBUS bindings are quite old.
