views:

593

answers:

3

Hi all,

In Thrift it is possible to use the oneway modifier to specify a call as asynchronous.

Apparently, it's not possible to define a callback, though, to be executed when the execution of the function is completed.

It seems that the only possibility I have is to give my Thrift client (PHP) some "server" capabilities, so that, when the heavy computation is completed on the server side, I can send a notification to it. This means that I should have a new .thrift file, with new definitions, new services and all the rest and that I should generate php-server side code with Thrift.

Even if this is feasible, it looks like an overkill to me and I'm wondering if there's a more clever way to implement the callback.

Looking forward for some feedback from you, guys.

+3  A: 
vladr
A: 

I've received an answer on a channel different from Stack Overflow. Since the author gave me permission to post here his answer, I thought it could be useful to someone else in the community.

Hey Robert,

Yeah, this has come up on the Apache lists before. There is no elegant way to do what you're asking for with Thrift. It's fundamentally not designed for bidirectional messaging.

There are hacks around this, such as: - client-side polling - invoking send_method(), waiting on the client side, then recv_method(), instead of just method() - making the client also implement a Thrift server

But obviously none of these are true bi-directional messaging. We've tried to keep the Thrift interfaces as simple as possible and focused on the core RPC use case, which has meant leaving some stuff like this out.

Probably not the answer you were hoping for.

Cheers, mcslee

Roberto Aloi
A: 

Well Java has Asynchronus Message calls through Future Object reference. This can be implemented in a RPC model using Message Pack. I am not sure if PHP has something similar.

sheki