Is there an easy way to split a full ZMsg message (envelope + request) into the envelope and the request? Right now I'm using a loop popping from the message until reaching the empty frame, but I was hoping there's an easier way.
Context: I'm working on a project using ZeroMQ where one of the programs, written in Java with JeroMQ, has a ROUTER frontend and a few REP backend threads. The ROUTER, upon receiving a message, decides depending on its contents which backend REP to redirect to. To redirect a message the ROUTER thread connects with a REQ to each of the backend threads.
However, since the ROUTER returns the full message (envelope + request, i.e. [IDs, "", X, Y, Z]), the REQ will send ["", IDs, "", X, Y, Z], and the REP will receive [IDs, "", X, Y, Z]. I figure the easiest way to deal with this is for the REP threads to split the message in two.
I just realized I should be using a DEALER in the router thread instead of a REQ for each of the backend workers! The DEALER doesn't prepend an empty reply envelope like the REQ does... Feels so obvious now.
Hello,
Is there an easy way to split a full
ZMsg
message (envelope + request) into the envelope and the request? Right now I'm using a loop popping from the message until reaching the empty frame, but I was hoping there's an easier way.Context: I'm working on a project using ZeroMQ where one of the programs, written in Java with JeroMQ, has a
ROUTER
frontend and a fewREP
backend threads. TheROUTER
, upon receiving a message, decides depending on its contents which backendREP
to redirect to. To redirect a message theROUTER
thread connects with aREQ
to each of the backend threads.However, since the
ROUTER
returns the full message (envelope + request, i.e.[IDs, "", X, Y, Z]
), theREQ
will send["", IDs, "", X, Y, Z]
, and theREP
will receive[IDs, "", X, Y, Z]
. I figure the easiest way to deal with this is for theREP
threads to split the message in two.