0

Is it possible to implement a two-way communication between client and server with Apache Thrift? Thus not only to be able to make RPC from client to server, but also the other way round? In my project I have the requirement that the server must also push some data to the client without being asked by the client before to do this.

Denis Kulagin
  • 8,472
  • 17
  • 60
  • 129
Thomas W.
  • 2,134
  • 2
  • 24
  • 46

2 Answers2

3

There are two ways how to achieve this with Thrift.

  1. If both ends are more or less peers and you connect them through sockets or pipes, you simply set up a server and a client on both ends and you're pretty much done. This does not work in all cases, however, especially with HTTP.

  2. If you connect server and client through HTTP or a similar channel, there is a technique called "long polling". It basically requires the client to call the server as usual, but the call will only return when the server wants to send some data back to the client. After receiving the data, the client starts another call if he's still interested in more data.

As Denis pointed out, depending on your exact use case, you might want to consider using a MQ system. Note that it is still possible to use Thrift to de/serialize the messages into and from the queues. The contrib folder has some examples that show how to use Thrift with ZMQ, Rebus and some others.

Community
  • 1
  • 1
JensG
  • 13,148
  • 4
  • 45
  • 55
0

You are better to use queues then, e.g. ZeroMQ.

Denis Kulagin
  • 8,472
  • 17
  • 60
  • 129
  • I'm not sure if that a) answers the question and b) fits the use case which the OP did not tell us in enough detail. Assuming you can set up a ZMQ connection (which is not even a real MQ system, by the way) assumes certain things which we don't know yet. – JensG Feb 26 '15 at 17:47