views:

38

answers:

1

I'm working on a solution to make certain data from a large database available to a remote website. My first thought was to simply cook up some soap web services to fetch certain data from the database. This could be done in just a few line, for instance like this, with the user of Zend_Soap_Server:

class MyClass 
{
    public function getlastname($id) 
    {
        $dbh = new PDO("oci:dbname=bigdb", "theuser", "thepass");

        $stmt = $dbh->prepare("select lastname from person where id  = :id"); 

        if ($stmt->execute(array(':id',$id))) 
        {
         $row = $stmt->fetch();
         return $row['lastname'];
        }
    }
}

$server = new Zend_Soap_Server(null, $options);
$server->setClass('MyClass');
$server->setObject(new MyClass());

$server->handle();

Now someone told me to also have a look at message brokers / queues. I've been taking a look at some software like apache activeMQ, stomp and zend_queue but I didn't really get a clear view what they should be used for and weather they would be useful in this project.

I do understand that my implementation could have some drawbacks, like a sluggish website when the database is not responding quickly and a high load on the database when there are coming lots of requests from the website, would a message broker be able to prevent such complications?

+1  A: 

Hello,

The role of a message broker is to check the requests and dispatch them to the right service or return a response from a cache.

If you are expecting large traffic you probably should consider using a message broker.

Regards, Alin

Alin Purcaru
Is a message broker also usefull for a situation like the soap call I describe? In this case, the sender (the website) expects a immediate answer.
Erikl
I don't think it has anything to do with the fact that a response is needed synchronously. The broker would just pull the response from your service and send it to the client. If caching is possible you could implement it in the broker, also you could add IP filtering, input validation, output filters or anything you like. This is question of how you want to design your application. Personally, I would use a broker.
Alin Purcaru
Thanks Alin, I think you're right.
Erikl