Wednesday, August 10, 2011

ZeroMQ support in Drizzle

My little zeromq plugin just hit drizzle trunk, it is simply a replication plugin that publishes a multi-frame message on a ZeroMQ endpoint. The first frame contains the name of the schema the transaction was executed against and the second frame is the actual protobuf-serialized transaction.

Getting started

  1. Install zeromq
  2. Build & install Drizzle (it will pick up the zeromq libs automatically)
  3. Start drizzled with --plugin-add=zeromq (this binds a zeromq socket on tcp://*:9999 - change this by setting --zeromq.endpoint=[whatever])
  4. Profit
Try it out by running this small python script:
import zmq

ctx = zmq.Context()
s = ctx.socket(zmq.SUB)
s.setsockopt(zmq.SUBSCRIBE, '')
i = 0
while True:
    i = i+1
    print s.recv_multipart()
    print i
You should see output on the form ['the_schema', *blob*].

No comments: