~ubuntu-branches/ubuntu/precise/pyzmq/precise

« back to all changes in this revision

Viewing changes to docs/source/devices.rst

  • Committer: Package Import Robot
  • Author(s): Debian Python Modules Team
  • Date: 2011-09-23 00:16:39 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: package-import@ubuntu.com-20110923001639-girjqodpb7uv17yu
Tags: 2.1.9-1
* New upstream version
  - should build on kFreeBSD without patches (Closes: #637777).
* Build-depend on zeromq 2.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
Cython, so the loop does not involve Python, and should have the same performance as the
53
53
basic ``QUEUE`` device.
54
54
 
55
 
One shortcoming of the ``QUEUE`` device is that it does not support having ``XREP``
56
 
sockets as both input and output. This is because ``XREP`` sockets, when they receive a
 
55
One shortcoming of the ``QUEUE`` device is that it does not support having ``ROUTER``
 
56
sockets as both input and output. This is because ``ROUTER`` sockets, when they receive a
57
57
message, prepend the ``IDENTITY`` of the socket that sent the message (for use in routing
58
58
the reply). The result is that the output socket will always try to route the incoming
59
59
message back to the original sender, which is presumably not the intended pattern. In
60
 
order for the queue to support an XREP-XREP connection, it must swap the first two parts
 
60
order for the queue to support a ROUTER-ROUTER connection, it must swap the first two parts
61
61
of the message in order to get the right message out the other side.
62
62
 
63
63
To invoke a monitored queue is similar to invoking a regular ØMQ device::
64
64
 
65
65
    from zmq.devices.monitoredqueue import monitored_queue
66
 
    ins = ctx.socket(zmq.XREP)
67
 
    outs = ctx.socket(zmq.XREQ)
 
66
    ins = ctx.socket(zmq.ROUTER)
 
67
    outs = ctx.socket(zmq.DEALER)
68
68
    mons = ctx.socket(zmq.PUB)
69
69
    configure_sockets(ins,outs,mons)
70
70
    monitored_queue(ins, outs, mons, in_prefix='in', out_prefix='out')