精华内容
下载资源
问答
  • zeromq rpc原型

    2016-10-30 17:34:00
    /* Asynchronous request-reply single-threaded server in Python that spawns a request handler each time a request is received This is different from other examples because the number of request ha.....
    /*
    Asynchronous request-reply single-threaded server in Python
    that spawns a request handler each time a request is received
    This is different from other examples because the number of request handler threads is not defined ahead of time.
    Request:
    Client DEALER --> Server ROUTER --> Request handler (spawned)
    1. Clients send requests via a DEALER socket on port 5570
    2. Server receives requests via a ROUTER socket on port 5570
    3. Server passes both the request and the client identity directly to request handlers when they are spawned
    Reply:
    Client DEALER <-- Server ROUTER <-- Server DEALER <-- Request handler DEALER
    1. Request handler returns the reply to the Server via a DEALER socket on inproc
    2. Server receives the reply from the request handler via a DEALER socket on inproc
    3. Server sends the reply to the client via a ROUTER socket on port 5570
    4. Client receives the reply via a DEALER socket on port 5570
    */
    
    using System;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using NetMQ;
    using NetMQ.Sockets;
    
    namespace NetmqSample
    {
        public class ZmqClient
        {
            public void Request(string input)
            {
                var socket = new DealerSocket();
                socket.Options.Identity = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString());
                socket.Connect("tcp://127.0.0.1:5570");
    
                socket.SendFrame(input);
                Console.WriteLine($"client send: {input} : {DateTime.Now:T}");
    
                var answer = socket.ReceiveFrameString();
                Console.WriteLine($"client received: {answer} : {DateTime.Now:T}");
    
                socket.Dispose();
            }
        }
    
        public class ZmqServer
        {
            private DealerSocket _backend;
            private RouterSocket _frontend;
    
            public void Run()
            {
                _frontend = new RouterSocket();
                _frontend.Bind("tcp://*:5570");
                _frontend.ReceiveReady += Frontend_ReceiveReady;
    
                _backend = new DealerSocket();
                _backend.Bind("inproc://backend");
                _backend.ReceiveReady += Backend_ReceiveReady;
    
                var poller = new NetMQPoller { _frontend, _backend };
                poller.RunAsync();
    
                Console.WriteLine("server started");
            }
    
            private void Backend_ReceiveReady(object sender, NetMQSocketEventArgs e)
            {
                var id = e.Socket.ReceiveFrameString();
                var msg = e.Socket.ReceiveFrameString();
    
                Console.WriteLine($"server backend response: {id} : {msg}");
                _frontend.SendFrame(id, true);
                _frontend.SendFrame(msg);
            }
    
            private void Frontend_ReceiveReady(object sender, NetMQSocketEventArgs e)
            {
                var id = e.Socket.ReceiveFrameString();
                var msg = e.Socket.ReceiveFrameString();
    
                //Console.WriteLine($"server frontend received: {id} : {msg} : {DateTime.Now:T}");
                var task = new Task(() => new RequestHandler().Run(id, msg), TaskCreationOptions.LongRunning);
                task.Start();
            }
        }
    
        public class RequestHandler
        {
            public void Run(string id, string msg)
            {
                var worker = new DealerSocket("inproc://backend");
    
                // Simulate a long-running operation
                Thread.Sleep(2000);
    
                worker.SendFrame(id, true);
                worker.SendFrame(msg + " : " + DateTime.Now.ToLongTimeString());
                worker.Dispose(); 
            }
        }
    }

     

        class Program
        {
            static void Main(string[] args)
            {
                var server = new ZmqServer();
                server.Run();
    
                Enumerable.Range(0, 2000).ToList().ForEach(x =>
                {
                    Task.Factory.StartNew(() => new ZmqClient().Request(x.ToString("0000")), TaskCreationOptions.LongRunning);
                });
    
                Console.ReadLine();
            }
        }

     

    转载于:https://www.cnblogs.com/zhahost/p/6013550.html

    展开全文
  • zeroRPC:zerorpc 是一个灵活的 RPC 实现,基于 ZeroMQ 和 MessagePack。
  • raise rpc_common.Timeout, "No match from matchmaker." # This supports brokerless fanout (addresses > 1) for queue in queues: (_topic, ip_addr) = queue _addr = "tcp://%s:%s" % (ip_addr, ...
  • python zeromq rpc介紹

    千次阅读 2011-12-27 08:35:44
    https://github.com/geoffwatts/zmqrpc 傳輸資料格式:bson 模型: 多線程 Client Server  ------ ------------------------------  client worker(thread)
    https://github.com/geoffwatts/zmqrpc
    傳輸資料格式:bson
    模型: 多線程
    Client             Server   
    ------       ------------------------------          
    client                        worker(thread)     
                 \                /
    cleint   --   queue    
                 /                \
    client                        worker(thread)

    server.py
    """
    server: Implementing ZMQRPCServer class to export a user class via zmqrpc to ZMQRPC clients, and to arrange queued calls to server threads.
    """
    
    import sys
    if sys.version < '2.6':
        sys.exit('ERROR: Sorry, python 2.6 is required for the way this module uses threading.')
    
    import zmq
    from bson import BSON   
    import threading
    import os, sys, traceback
    from zmqrpc import ZMQRPCError, ZMQRPCRemoteError
    
    
    LISTEN=0
    CONNECT=1
    
    class ZMQRPCServer(object):
        def _thread(self,context,worker_id,import_class,pid,serverid,counters,methods,target,stype,worker_args):
            """
            Worker thread for zmqrpc server - binds to zmq socket (target) and works ZMQRPCServer import_class.
            Instantiated by work() threading
            Handles BSON in/out, zmq REP to zmq QUEUE or REQ
            """
            socket = self.context.socket(zmq.REP)
            job_count = 0
            if stype == LISTEN:
                socket.bind(target)
            else:
                socket.connect(target)
    
            if worker_args:
                nuclass = import_class(**worker_args)
            else:
                nuclass = import_class()
            
            while True:
                sockin = socket.recv()
                message = BSON(sockin).decode()
                result = None
                fail = None
                tb = None
                method = str(message['method'])
                args = message.get('args',[])
                if self.export and (not method in self.export):
                    tb = "NameError: name '"+method+"' is not exported in ZMQRPC class '"+import_class.__name__+"'"
                    socket.send(BSON.encode({'fail':True,'result':None,'runner':None,'traceback':tb}))
                    return
                    
    
                # Convert kwargs from unicode strings to 8bit strings
                
                if method == '__threadstatus__':
                    x = threading.current_thread()
                    socket.send(BSON.encode({'runner':None,'traceback':None,'fail':False,'result':{'id':serverid+':'+str(pid)+':'+str(x.name),'alive':x.is_alive(),'job_count':counters.get(x.name,0),'last_method':methods.get(x.name,''),}}))   
                else:
                    try:
                        kwargs = {}
                        for (k,v) in message.get('kwargs',{}).iteritems():
                            kwargs[str(k)] = v
    
                        job_count+=1
                        counters[threading.currentThread().name] = job_count
                        methods[threading.currentThread().name] = method
                        runner = {'job_count':job_count,'thread':threading.currentThread().name,'method':import_class.__name__+'.'+method,}
                        
                        # Find the method in the module, run it.
                        try:
                            if hasattr(nuclass,method):
                                result = getattr(nuclass,method)(*args,**kwargs)
                                fail = False
                            else:
                                fail = True
                                tb = "NameError: name '"+method+"' is not defined in ZMQRPC class '"+import_class.__name__+"'"
                        except:
                            etype, evalue, etb = sys.exc_info()
                            fail = True
                            tb = "\n".join(traceback.format_exception(etype, evalue, etb))
                        socket.send(BSON.encode({'fail':fail,'result':result,'runner':runner,'traceback':tb}))
                    except:
                        etype, evalue, etb = sys.exc_info()
                        fail = True
                        tb = "\n".join(traceback.format_exception(etype, evalue, etb))
                        socket.send(BSON.encode({'fail':fail,'result':None,'runner':None,'traceback':tb}))
    
    
        def __init__(self,import_class,export=None):
            """
            Instantiate this class with your class to export via zmqrpc
            """
            self.iclass = import_class
            self.pid = os.getpid()
            self.serverid = os.uname()[1]
            self.context = zmq.Context(1)
            self.export = export
    
        def work(self,workers=1,target="inproc://workers",stype=CONNECT,worker_args={}):
            """
            Call to spawn serverthreads that will then work forever.
            stype: socket type, either zmqrpc.server.CONNECT or zmqrpc.server.LISTEN
            target: zmq socket (eg: 'tcp://127.0.0.1:5000')
            workers: number of worker threads to spwan
            """
            counters = {}
            methods = {}
            for i in range(0,workers):
                thread = threading.Thread(target=self._thread, name='zmqrpc-'+str(i), args=(self.context,i,self.iclass,self.pid,self.serverid,counters,methods,target,stype,worker_args))
                thread.start()
    
                
        def queue(self,listen,bind='inproc://workers',thread=False):
            """
            Call to start a zmq queue device to disatch zmqrpc work.
            listen: zmq socket to listen on for CLIENTS (eg: 'tcp://127.0.0.1:5 000')
            target: zmq socket to listen on for worker threads (eg: 'tcp://127.0.0.1:6000')
            workers: number of worker threads to spwan
            """
            def q(listen,worker_target):
                self.workers = self.context.socket(zmq.XREQ)
                self.workers.bind(worker_target);
    
                self.clients = self.context.socket(zmq.XREP)
                self.clients.bind(listen) 
                zmq.device(zmq.QUEUE, self.clients, self.workers)
            if thread:
                thread = threading.Thread(target=q, name='zmqrpc-queue', args=(listen,bind ))
                thread.start()
            else:
                q(listen,bind)
            

    client.py
    """client: client class to export a class to an zmqrpc queue or client."""
    import zmq
    from bson import BSON   
    import os, sys, traceback
    import time
    
    from zmqrpc import ZMQRPCError, ZMQRPCRemoteError
    
    class ZMQRPC(object):
        """
        ZMQRPC: client class to export a class to an zmqrpc queue or client.
        """
        def __init__(self,target,timeout=30):
            """
            Instantiate this class with a zmq target (eg 'tcp://127.0.0.1:5000') and a timeout (in seconds) for method calls.
            Then call zmqrpc server exported methods from the class.
            """
            
            self._context = zmq.Context()
            self._zmqsocket = self._context.socket(zmq.REQ)
            # Connect to everything, or just one
            if isinstance(target,list):
                for t in target:
                    self._zmqsocket.connect(target)
            else:
                self._zmqsocket.connect(target)
            self._socket = target
            self._pollin = zmq.Poller()
            self._pollin.register(self._zmqsocket,zmq.POLLIN)
            self._pollout = zmq.Poller()
            self._pollout.register(self._zmqsocket,zmq.POLLOUT)
            self._timeout = timeout
            
            self._lastrun = None
    
        def _dorequest(self,msg,timeout=5):
            """
            _dorequest: Set up a BSON string and send zmq REQ to ZMQRPC target
            """
            # Set up bson message
            bson = BSON.encode(msg)
            
            # Send...
            try:
                self._pollout.poll(timeout=timeout*1000) # Poll for outbound send, then send
                self._zmqsocket.send(bson,flags=zmq.NOBLOCK)
            except:
                raise ZMQRPCError('Request failure')
    
            # Poll for inbound then rx
            try:        
                for i in range(0,timeout*100):
                    if len(self._pollin.poll(timeout=1)) > 0:
                        break
                    time.sleep(0.01)
                msg_in = self._zmqsocket.recv(flags=zmq.NOBLOCK)
            
            except:
                raise ZMQRPCError('Response timeout')
    
            
            if msg_in == None:
                raise ZMQRPCError('No response')
        
            result = BSON(msg_in).decode()
            
            self._lastrun = result.get('runner')
            
            return result
        
        
        def _debug_call(self,name,*args,**kwargs):
            """
            _debug_call: Convenience method to call _dorequest with pre-filled dict with method name, args, kwargs and timeout
            """
            return self._dorequest({'method':name,'args':args,'kwargs':kwargs},timeout=self._timeout)
                   
        def __serverstatus__(self,max_nodes=1000):
            """
            __serverstatus__: Slightly hackish method to retreive threadstatus from all listening threads on a zmqrpc queue
            """
            results = {}
            try:
                for r in range(0,max_nodes):
                    res = self._dorequest({'method':'__threadstatus__'},timeout=self._timeout)[u'result']
                    id = res[u'id']
                    if results.has_key(id): break
                    del res[u'id']
                    results[id] = res
            except:
                raise ZMQRPCError('Error finding server threads')
            return results
                
                
             
        class RPC(object):
            """
            RPC: zmqrpc Remote procedure call class - encapsulates method calls to imported class
            """
    
            def __init__(self,name,fn,timeout,target):
                self._name = name
                self._fn = fn
                self._timeout = timeout
                self._socket = target
                
            def __call__(self,*args,**kwargs):
                result = self._fn({'method':self._name,'args':args,'kwargs':kwargs},timeout=self._timeout)
                if result['fail']:
                    raise ZMQRPCRemoteError(result['traceback']) #+"  RUNNER:"+str(result['runner']))
                else:
                    return result['result']
            def __repr__(self):
                return '<zmqrpc method '+self._name+' to zmq socket '+self._socket+'>'
                
            
        def __getattr__(self,name):
                return self.RPC(name,self._dorequest,timeout=self._timeout,target=self._socket)
     
    


    由於是使用zmq所以很容易把上面的模式改進為,多進程+多線程的模型
    因為python中是鼓勵使用多進程的(多進程可使用多核)
    模型二: 多進程+多線程
    Client             Server   
    ------       ----------------------------------------------          
    client                       Server1________worker(thread)
                 \                /(process)    \___worker(thread)
    cleint   --   queue    
                 /                \                                      
    client                       Server2________worker(thread)
                                    (process)    \___worker(thread)

    要使用模型二需要把传输协议由INPROC改為IPC






    展开全文
  • zerorpc zerorpc is a flexible RPC implementation based on zeromq and messagepack. Service APIs exposed with zerorpc are called "zeroservices".zerorpc can be used programmatically or from the command-l...

    zerorpc

    68747470733a2f2f7472617669732d63692e6f72672f307270632f7a65726f7270632d707974686f6e2e7376673f6272616e63683d6d6173746572

    zerorpc is a flexible RPC implementation based on zeromq and messagepack. Service APIs exposed with zerorpc are called "zeroservices".

    zerorpc can be used programmatically or from the command-line. It comes with a convenient script, "zerorpc", allowing to:

    expose Python modules without modifying a single line of code,

    call those modules remotely through the command line.

    Installation

    On most systems, its a matter of:

    $ pip install zerorpc

    Depending of the support from Gevent and PyZMQ on your system, you might need to install libev (for gevent) and libzmq (for pyzmq) with the development files.

    Create a server with a one-liner

    Let's see zerorpc in action with a simple example. In a first terminal, we will expose the Python "time" module:

    $ zerorpc --server --bind tcp://*:1234 time

    Note

    The bind address uses the zeromq address format. You are not limited to TCP transport: you could as well specify ipc:///tmp/time to use host-local sockets, for instance. "tcp://*:1234" is a short-hand to "tcp://0.0.0.0:1234" and means "listen on TCP port 1234, accepting connections on all IP addresses".

    Call the server from the command-line

    Now, in another terminal, call the exposed module:

    $ zerorpc --client --connect tcp://127.0.0.1:1234 strftime %Y/%m/%d

    Connecting to "tcp://127.0.0.1:1234"

    "2011/03/07"

    Since the client usecase is the most common one, "--client" is the default parameter, and you can remove it safely:

    $ zerorpc --connect tcp://127.0.0.1:1234 strftime %Y/%m/%d

    Connecting to "tcp://127.0.0.1:1234"

    "2011/03/07"

    Moreover, since the most common usecase is to connect (as opposed to bind) you can also omit "--connect":

    $ zerorpc tcp://127.0.0.1:1234 strftime %Y/%m/%d

    Connecting to "tcp://127.0.0.1:1234"

    "2011/03/07"

    See remote service documentation

    You can introspect the remote service; it happens automatically if you don't specify the name of the function you want to call:

    $ zerorpc tcp://127.0.0.1:1234

    Connecting to "tcp://127.0.0.1:1234"

    tzset tzset(zone)

    ctime ctime(seconds) -> string

    clock clock() -> floating point number

    struct_time

    time time() -> floating point number

    strptime strptime(string, format) -> struct_time

    gmtime gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,

    mktime mktime(tuple) -> floating point number

    sleep sleep(seconds)

    asctime asctime([tuple]) -> string

    strftime strftime(format[, tuple]) -> string

    localtime localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,

    Specifying non-string arguments

    Now, see what happens if we try to call a function expecting a non-string argument:

    $ zerorpc tcp://127.0.0.1:1234 sleep 3

    Connecting to "tcp://127.0.0.1:1234"

    Traceback (most recent call last):

    [...]

    TypeError: a float is required

    That's because all command-line arguments are handled as strings. Don't worry, we can specify any kind of argument using JSON encoding:

    $ zerorpc --json tcp://127.0.0.1:1234 sleep 3

    Connecting to "tcp://127.0.0.1:1234"

    [wait for 3 seconds...]

    null

    zeroworkers: reversing bind and connect

    Sometimes, you don't want your client to connect to the server; you want your server to act as a kind of worker, and connect to a hub or queue which will dispatch requests. You can achieve this by swapping "--bind" and "--connect":

    $ zerorpc --bind tcp://*:1234 strftime %Y/%m/%d

    We now have "something" wanting to call the "strftime" function, and waiting for a worker to connect to it. Let's start the worker:

    $ zerorpc --server tcp://127.0.0.1:1234 time

    The worker will connect to the listening client and ask him "what should I do?"; the client will send the "strftime" function call; the worker will execute it and return the result. The first program will display the local time and exit. The worker will remain running.

    Listening on multiple addresses

    What if you want to run the same server on multiple addresses? Just repeat the "--bind" option:

    $ zerorpc --server --bind tcp://*:1234 --bind ipc:///tmp/time time

    You can then connect to it using either "zerorpc tcp://*:1234" or "zerorpc ipc:///tmp/time".

    Wait, there is more! You can even mix "--bind" and "--connect". That means that your server will wait for requests on a given address, and connect as a worker on another. Likewise, you can specify "--connect" multiple times, so your worker will connect to multiple queues. If a queue is not running, it won't affect the worker (that's the magic of zeromq).

    Warning

    A client should probably not connect to multiple addresses!

    Almost all other scenarios will work; but if you ask a client to connect to multiple addresses, and at least one of them has no server at the end, the client will ultimately block. A client can, however, bind multiple addresses, and will dispatch requests to available workers. If you want to connect to multiple remote servers for high availability purposes, you insert something like HAProxy in the middle.

    Exposing a zeroservice programmatically

    Of course, the command-line is simply a convenience wrapper for the zerorpc python API. Below are a few examples.

    Here's how to expose an object of your choice as a zeroservice:

    class Cooler(object):

    """ Various convenience methods to make things cooler. """

    def add_man(self, sentence):

    """ End a sentence with ", man!" to make it sound cooler, and

    return the result. """

    return sentence + ", man!"

    def add_42(self, n):

    """ Add 42 to an integer argument to make it cooler, and return the

    result. """

    return n + 42

    def boat(self, sentence):

    """ Replace a sentence with "I'm on a boat!", and return that,

    because it's cooler. """

    return "I'm on a boat!"

    import zerorpc

    s = zerorpc.Server(Cooler())

    s.bind("tcp://0.0.0.0:4242")

    s.run()

    Let's save this code to cooler.py and run it:

    $ python cooler.py

    Now, in another terminal, let's try connecting to our awesome zeroservice:

    $ zerorpc -j tcp://localhost:4242 add_42 1

    43

    $ zerorpc tcp://localhost:4242 add_man 'I own a mint-condition Volkswagen Golf'

    "I own a mint-condition Volkswagen Golf, man!"

    $ zerorpc tcp://localhost:4242 boat 'I own a mint-condition Volkswagen Golf, man!'

    "I'm on a boat!"

    Congratulations! You have just made the World a little cooler with your first zeroservice, man!

    展开全文
  • Zeromq 是基于zeromq、gevent和 msgpack开发的分布式RPC框架zerorpc-python。这个框架简单、易用。 1. 安装zeromq 1 2 3 4 5 6 yum -y install zeromq yum install gcc gcc-c++ libuuid-devel python-uuid ...

    Zeromq 是基于zeromq、gevent和 msgpack开发的分布式RPC框架zerorpc-python。这个框架简单、易用。


    1. 安装zeromq

    1
    2
    3
    4
    5
    6
    yum -y install zeromq
    yum install gcc gcc-c++ libuuid-devel python-uuid uuid
    wget http://download.zeromq.org/zeromq-2.1.9.tar.gz
    ./configure
    make
    make install


    2.安装gevent

    1
    pip install gevent


    3.  安装zerorpc

    1
    pip install zerorpc




    server的测试代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    import zerorpc
    import time
    class HelloRPC(object):
        def hello(self, name):
            print   "this is %s  %s" %(name,time.strftime('%Y-%m-%d %H-%m-%S',time.localtime(time.time())))
            return "Hello, %s" %time.strftime('%Y-%m-%d %H-%m-%S',time.localtime(time.time()))
    s = zerorpc.Server(HelloRPC())
    s.bind("tcp://0.0.0.0:4242")
    s.run()



    222442261.jpg


    222312425.jpg


    client的测试代码


    1
    2
    3
    4
    5
    import zerorpc
    import os,sys
    = zerorpc.Client()
    c.connect("tcp://127.0.0.1:4242")
    print c.hello('www.ruifengyun.com')


    222537291.jpg


    也可以传送cmd的命令,然后return结果,这个有点像是 zeromq的req方法

    223810510.jpg

    客户端也可以独立的存在

    1
    zerorpc --client --connect tcp://127.0.0.1:4242 hello lllllllllllllllllllllllllll


    客户端显示:


    224507360.jpg


    服务端显示:

    224702901.jpg


    现在看来,如果按照mq的性能对比的话,这个结果还是令人不太满意的,但这个是应用于rpc远程调用的场景内,外部调用的话一秒中可以可以发送并接受10次的调用,内部调用的话,可以每秒钟打到300次左右,但这个结果还是可以接受的,毕竟没有谁每时每刻都在用远端的函数的。。。。。。。

    这个一个老外的测试数据:


    1
    2
    3
    4
    xmlrpc client & server (single-threaded): 850 calls/sec
    zerorpc client & server (single-threaded): 4500 calls/sec
    xmlrpc client & server (multi-threaded): 1200 calls/sec
    zerorpc client & server (multi-threaded): 11000 calls/sec


    我很纳闷他是怎么测试出来的~

    如果不需要return结果,只是类pub数据过去的话,是可以到600多,但是远达不到他们的数据。。。

    很奇怪~

    为了测试性能我把gevent引入了,测试的结果不稳定,以我对gevent协程框架的使用,他很少出这样的情况,问题很有可能是server的问题。。。


    235228883.jpg

    测试的结果:

    235714474.jpg



    完成的测试代码,以供大家学习测试:

    server 测试代码:


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    class Cooler:
        def add_man(self, sentence):
            return the result. """
            return sentence + ", man!"
        def add_42(self, n):
            result. """
            return n + 42
        def boat(self, sentence):
            because it's cooler. """
            return "I'm on a boat!"
    import zerorpc
    s = zerorpc.Server(Cooler())
    s.bind("tcp://0.0.0.0:4242")
    s.run()


    client 测试代码:


    1
    2
    3
    4
    5
    6
    $ zerorpc -j tcp://:4242 add_42 1
    43
    $ zerorpc tcp://:4242 add_man 'I own a mint-condition Volkswagen Golf'
    "I own a mint-condition Volkswagen Golf, man!"
    $ zerorpc tcp://:4242 boat 'I own a mint-condition Volkswagen Golf, man!'
    "I'm on a boat!"



    zerorpc 官方推荐的高可用的方法是用haproxy实现的


    1
    2
    3
    4
    5
    6
    7
    8
    haproxy.cfg的配置
    $cat haproxy.cfg
    listen zerorpc 0.0.0.0:1111
        mode tcp
        server backend_a localhost:2222 check
        server backend_b localhost:3333 check
    检测语法
    $ haproxy -f haproxy.cfg


    可以进行语句的超时处理

    231023715.jpg





     本文转自 rfyiamcool 51CTO博客,原文链接:http://blog.51cto.com/rfyiamcool/1254000,如需转载请自行联系原作者




    展开全文
  • Zeromq 学习笔记1

    2019-09-25 14:39:44
    zmq总体功能比较强劲,可实现ipc rpc 订阅分发 进程内通信 等等 总体图: ctx_t 是所有zmq 的容器。负责管理 zmq socket iothread 和 session。 先从 ctx_t说起 void *zmq_init (int io_threads_) { if (i.....
  • zeromq v.s. xmlrpc(http)

    2019-07-01 23:10:00
    zeromq是通过消息队列的方式来进行进程间通信的,所以它算作是一种RPC方法?(自己想的,需要求证) ROS的xmlrpc不是被opendds给替换了么。opendds在美军中有成功应用 https://stackoverflow...
  • 环境Ubuntu 14.04 + gcc/g++4.8.4 +Python 2.7需求最近在搞一个项目,需要让C++和...网上看到有人用socket解决,可本人对socket一向排斥,然后就采用了更强大的分布式RPC框架——ZeroMQ来让二者交互。ZeroMQ介绍Zero...
  • think about the simple pirate pattern and implementing an RPC style call set in that pattern with zeromq. <pre><code>Socket; //zeromq socket //routine 1 socket.send(data) // do i need some ...
  • <div><p>as of pyzmq==2.2.0.1 gevent support is included via zmq.green as per zeromq/pyzmq#190 <p>Since you already required >=2.2.0.1 in setup.py it would ...0rpc/zerorpc-python</p></div>
  • ActiveMQ;RabbitMQ;ZeroMQ

    2016-04-10 23:39:00
    中间件类型: Embedded middleware: As the name suggests, this typeof middleware handles embedded applications (software or ...RPC middleware: RPC (Remote Procedure Call)middleware communica...
  • <p>zeromq-4.3.1 The ZeroMQ messaging library <p>Which was installed from <a href="https://pkgsrc.org">pkgsrc</a> - the standard way to install packages on SmartOS. <p>Compilation fails with: <pre>...
  • m not sure yet what protocol to talk, maybe the Protobuf RPC Service definitions over ZMQ, or is that overly complex? <p>So I just want to sanity check that a) nothing like this already exists, and b)...
  • #RPC 方案配置 实际项目中,使用过zmq,也使用过pomelo-rpc, 方案1 zmq //配置zmq var zmq = require('pomelo-rpc-zeromq-renew');//0.0.9版本 app.set('proxyConfig', { rpcClient:...
  • 一 Python中RPC框架自带的:SimpleXMLRPCServer(数据包大,速度慢)第三方:ZeroRPC(底层使用ZeroMQ和MessagePack,速度快,响应时间短,并发高),grpc(谷歌推出支持夸语言)二 SimpleXMLRPCServer使用服务端from ...
  • 消息中间件部署及比较:rabbitMQ、activeMQ、zeroMQ、rocketMQ、Kafka、redis jms 消息中间件的作用 1、流量销峰 2、 应用间解耦 3、 异步处理 4、rpc实现方式之一 一发一存一消费,没有最好的消息队列中间件(简称...
  • <div><p>Running dashd 0.12.2.1 on Windows 10. ...rpcport=9998 rpcallowip=0.0.0.0/0 uacomment=bitcore debug=zmq</p><p>该提问来源于开源项目:dashpay/dash</p></div>
  • rpc使构建分布式系统简单许多,在云计算的实现中有很广泛的应用 ...zerorpc 是基于 ZeroMQ 和 MessagePack,速度相对快,响应时间短,并发高zerorpc需要额外安装,而SimpleXMLRPCServer不需要额外安装,但是SimpleX
  • <div><p>This adds an rpc subpackage to zmq and implements a "simple" RPC service. This version is focused only on the request/reply pattern, but handles load balancing ...zeromq/pyzmq</p></div>
  • Bindings for node.js and io.js to ZeroMQ', 36 silly install resolved main: 'index', 36 silly install resolved repository: 36 silly install resolved { type: 'git', 36 silly install ...
  • 选型:RabbitMQ、ActiveMQ/Apollo、ZeroMQ、memcacheQ、Redis、MSMQ、kafka/jafka 场景: 1、消息的发送者和消费者需要解耦的情况 2、发送者并不明确谁是消费者 3、发送者并不关心谁来消费消息 4、各个消费者...
  • /home/yisheng/workplace/spartan/spartan/rpc/zeromq.py", line 261, in _run if event & zmq.POLLIN: s.handle_read(s) File "/home/yisheng/workplace/spartan/spartan/rpc/zeromq.py", line ...
  • ZeroMQ(使用Curve进行身份验证/加密) 无限的邮件大小 低延迟 纯TCP连接 Apache Kafka(带有TLSv1.2) 持久性(消息可以重播) 高通量 HTTP1.1 / HTTPS(带有TLSv1.2) 低延迟 高通量 gRPC(使用TLSv1.2) ...
  • 现有的软件中用了大量的COM接口,导致无法跨平台,当然由于与Windows结合的太紧密,还有很多无法跨平台的地方。那么为了实现跨平台,支持Linux系统,以及后续的... RPC通信框架 CORBA ICE Thrift zeromq dbus RCF ...

空空如也

空空如也

1 2 3 4 5 ... 9
收藏数 162
精华内容 64
关键字:

rpczeromq