[zeromq-dev] Forwarding ROUTER to PUB
Charles Remes
lists at chuckremes.com
Thu Jan 16 18:46:44 CET 2014
Create a socket for each worker thread and have your main thread resend the message down the appropriate socket. Sometimes it isn’t a good idea to try and shoe-horn every zeromq socket pattern into your app. :)
On Jan 16, 2014, at 9:54 AM, Lindley French <lindleyf at gmail.com> wrote:
> A problem I was wrestling with was, how do I deal with a TCP connection where messages of different types may arrive, and may need to be dealt with in different threads? The TCP socket can't be touched directly by multiple threads, of course. The obvious solution was to immediately forward messages arriving on the TCP socket to an inproc socket.
>
> I then took it one step further: why not make that inproc socket a PUB socket and make the first part of each message be a topic identifier, so that whichever thread knows how to deal with a particular message can just subscribe to it and ignore the rest?
>
> That's a great design, right up until I try to do it with the TCP socket being a ROUTER. Now, no matter what the first part of the sent message is, the identity will end up being the first part on the receiving end. The PUB/SUB won't work without some tweaking.
>
> I don't want to just drop the identity; that's useful information. I could swap the first two parts; that will work, but it's unintuitive and could cause confusion down the road.
>
> Any other ideas?
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list