Receiving asynchronous messages by thrift client

I use Apache Thrift to define a protocol. I would like the client to receive asynchronous messages from the server.

service ServerService {
    oneway void async_server_hello(1: string message_from_client);
    string sync_server_hello(1: string message_from_client);
}

service ClientService { // how to use it from the server side?
    oneway void async_client_hello(1: string message_from_server);
}

I know how to connect to the server, send sync and async messages to the server, but I don't know how to send async messages from the server to the connected client.

(Python or Erlang code is preferable, but any other language will do)

Answers


Bidi-messaging is not possible with Apache Thrift. The server always reacts on client requests (except for oneway, of course). If you want the server to call the client back, the client has to set up an server on it's own. Another option could be long-running calls to simulate the desired behaviour.

I have seen at least one fork on Github doing Bidi-Messaging, but

  • I don't know what the state of this/these project(s) is, and
  • that stuff is not part of the Apache Thrift project.

There are a bunch of JIRA tickets dealing with this topic, the essence is however that Thrift will not support this in near future, because one of the goals is simplicity, which Bidi is not per se, esepcially across transports and languages.

So there are solutions, but no built-in way that will do this automatically for you.


Need Your Help

How to serialize IEnumerable of Anonymous Type in C# to JavaScript Object?

c# javascript asp.net serialization

In my ASP.net C# code, I have an IEnumerable container filled with objects of an anonymous type (which is loosely based on data from SQL).

iOS development certificate and provisioning profile, possible without internet on the Mac?

ios certificate

I have enrolled in the iOS developer's program. I've developed an app which I would like to test on an iPad device. For security reasons, I cannot have a direct internet connection on the Mac I am