[zeromq-dev] XREP vs. ROUTER

Martin Lucina mato at kotelna.sk
Fri Mar 18 14:36:28 CET 2011

sustrik at 250bpm.com said:
> Lately, there's lot of usage of XREP as a router, so we have to deal 
> with it somehow.
> I think there are 3 basic attitudes to the problem to choose from:
> 1. Routing is a low-level functionality used to build 0MQ patterns on 
> top of it. This layer is equivalent to generic networking frameworks 
> such as ACE or Boost.Asio. If so, libzmq should be separated into 2 
> libraries, one providing the basic networking functionality, the other, 
> being layered on top of it, providing well-designed messaging patters.

As Pieter says, this is the current situation, except that people are
"unofficially" using XREP sockets to do their own custom routing, to
implement a "better" REQ/REP pattern which provides some form of
"reliability", and so on.

I don't see any value in splitting the library into two separate things,
why would you want to consider that?

> 2. Routing to address is a separate messaging pattern and should be 
> exposed as such. Routing to address is definitely a stand-alone 
> messaging pattern that is implemented by protocols such as SMTP, XMPP 
> and even IP as such. I deliberately haven't introduced it to 0MQ along 
> with other messaging patters, given it's well supported by other 
> products and really complex to implement (propagation of routing tables 
> etc.) However, if there's enough interest and resources to support such 
> a pattern, nothing prevents us to add new socket types etc.

People are using XREP as a "router". Ergo, there is demand for this

AFAICS this demand comes from several different groups of people:

1) People who want an improved REQ/REP model. Retransmission, recovery from
wedged states, sending more than one request asynchronously. All of these
are valid parts of a REQ/REP model.

2) People who wish to do completely custom routing or filtering of
messages. E.g. similar to an AMQP headers exchange.

3) People who just want to use 0MQ as "smart message-oriented sockets" and
don't give a damn about scalability or high level messaging patterns

Group 1) should be done by improving REQ/REP in the core, but someone has
to do it up to core standards. If it's not there, people will want a
"router" to do it themselves.

Group 2) looks like a valid case for a "router" socket of some kind.

Group 3) are the people you (Martin) dislike the most based on our many
discussions. But, look at it optimistically. They will do their thing, and
some of them will eventually see the light and move on to nice, globally
scalable, high-level messaging patterns. In the mean time, if we give them
functionality to do what they want *right now*, they will be happy and get
us more users, some of which will see the light, and so on and so on :-)

> 3. Routing to an address is not an valid and/or redundant pattern and 
> thus people are using XREP as an router at their own risk and should 
> expect strange behaviour (such as silent dropping of unroutable 
> messages) to happen.

Too late for that now :-(



More information about the zeromq-dev mailing list