[zeromq-dev] Reply-Request Pattern: Accessing a specific server method with a client request message?
MinRK
benjaminrk at gmail.com
Mon Apr 28 19:49:58 CEST 2014
On Mon, Apr 28, 2014 at 10:16 AM, Michel Pelletier <
pelletier.michel at gmail.com> wrote:
> 0mq only works with messages. If you want to messages to indicate
> functions to be called or arguments to be passed, you have to do that work
> yourself. 0mq doesn't know what a Python function is, or how to serialize
> a list of arguments. Thankfully it is relatively straightforward in Python
> and in many other languages to accomplish this and has already been done.
> Check out ZeroRPC, it's a Remote Procedure Call library that works over
> zeromq:
>
> http://zerorpc.dotcloud.com/
>
> zerorpc isn't your only option, there are many rpc libraries for Python,
> most of which don't use 0mq.
>
>
> http://stackoverflow.com/questions/1879971/what-is-the-current-choice-for-doing-rpc-in-python
>
And there are many that do:
https://pypi.python.org/pypi?%3Aaction=search&term=zeromq+rpc&submit=search
-MinRK
>
>
> -Michel
>
>
> On Mon, Apr 28, 2014 at 9:15 AM, Jess Updegrove <jessupde at gmail.com>wrote:
>
>> Hello Community!
>>
>> I'm a new programmer and I'm trying to build a server that has a bunch of
>> different functions. I want the architecture to be server-client, in which
>> a client can connect to the server, send it a list of parameters and the
>> function it wants the result from, and get a reply. However, I just cannot
>> seem to figure out how to do this in ZMQ and I'm looking for guidance. I'm
>> using Python (2.7) and the pyzmq library with the latest version of ZMQ.
>> I've read the Guide multiple times and looked through a bunch of examples.
>> Essentially, I want the convo between the client and server to go something
>> like this:
>>
>> C: Server, give me the current temperature in Seattle, Washington using
>> the function get_weather()
>> S: Accessing get_weather() with argument "Seattle" [goes to it's function
>> and gets the result]
>> S: Here's the result!
>> C: Server, change the temperature (in a database) for Seattle from 50 to
>> 70.
>> S: Accessing change_value() with key temperature.Seattle.
>> S: Value updated!
>>
>> However, I can only find examples that allow me to send a message but
>> not specify a list of arguments. I also just can't seem to figure out the
>> best way to send a message from the client and have the server pick it
>> apart and figure out which function to call without using a ton of if
>> statements checking the message content. Is ZMQ suitable for what I'm
>> doing? Am I approaching it incorrectly? Also note that I already built a
>> similar architecture like this is WAMPV2 using RPC calls and that's
>> essentially what I'm trying to replicate. I'm new with the terminology used
>> by ZMQ (sockets, threads, etc.) so it's very likely I'm just confused about
>> how it all works. Any help would be appreciated!
>>
>> Thanks
>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140428/6a6ce383/attachment.htm>
More information about the zeromq-dev
mailing list