问题
I need to write a client-server application in C++ using ZeroMQ push-pull socket pattern. The client has to make RPC calls to the functions specified in the server interface. I wonder if there is an open source and commercially usable library/framework for this purpose primarily in C++. I made some googling and there seem to be things written in python but I prefer something in C++ that comes handy with ZeroMQ if possible. Any suggestion/guidance is appreciated. Thanks.
回答1:
Google protobuf provides to generate client method wrappers and stubs for RPC services usable in C++.
The user must explicitly define the transport mechanism used for this, ZeroMQ would be an appropriate choice for implementation IMHO (So this is other way round as you have asked, but makes no difference in the end).
There's another SO question that provides some more details about the available alternatives: 'Which rpc/messaging framework would best fit this case?'
回答2:
Thrift RPC framework plays well with ZeroMQ REQ/REP sockets as a transport. Thrift source repository contains a sample in C++ that has couple of reusable classes: https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=tree;f=contrib/zeromq;h=14bbc6f51dae649b423f9157c08abac27157d416;hb=HEAD
Recently I started ThriftZMQ open-source project with the goal to implement interoperable ZeroMQ transport for Thrift in different languages. However, for now it only has Java implementation: https://github.com/thriftzmq
来源:https://stackoverflow.com/questions/14830304/rpc-framework-in-c-utilizing-zeromq