Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f52c454a0e
Fetching contributors…

Cannot retrieve contributors at this time

file 46 lines (38 sloc) 1.286 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
/*
* Custom routing Router to Papa (ROUTER to REP)
*
*
* @Author: Giovanni Ruggiero
* @Email: giovanni.ruggiero@gmail.com
*/

import org.zeromq.ZMQ
import ZHelpers._

object rtpapa {
  def main(args : Array[String]) {
val NOFLAGS = 0
// We will do this all in one thread to emphasize the sequence
// of events...
val ctx = ZMQ.context(1)
val client = ctx.socket(ZMQ.ROUTER)
val worker = ctx.socket(ZMQ.REP)

client.bind("inproc://routing")
worker.setIdentity("A".getBytes)
worker.connect("inproc://routing")

// Wait for the worker to connect so that when we send a message
// with routing envelope, it will actually match the worker...
Thread.sleep(1000)

// Send papa address, address stack, empty part, and request
client.send("A".getBytes, ZMQ.SNDMORE)
client.send("address 3".getBytes, ZMQ.SNDMORE)
client.send("address 2".getBytes, ZMQ.SNDMORE)
client.send("address 1".getBytes, ZMQ.SNDMORE)
client.send("".getBytes, ZMQ.SNDMORE)
client.send("This is the workload".getBytes, NOFLAGS)

// Worker should get just the workload
dump(worker)

// We don't play with envelopes in the worker
worker.send("This is the reply".getBytes, NOFLAGS)

// Now dump what we got off the ROUTER socket...
dump(client)
}
}
Something went wrong with that request. Please try again.