Hi Jun,
> I'm very excited to find that CAF is the one framework that I want and fills the gap in C++ with very high quality implementation. After I find CAF I decide to use it as the backbone of my project.
just out of curiosity: how did you find out about CAF? Where you explicitly searching for "actor model c++"?
> I am mostly working on the financial services area, the market data population requires high-throughput and low-latency transport. Zeromq pub/sub is a quite popular choice for this task (yes there are messages lost, but as stock market data is always updating so the lost is tolerable, like in streaming video).
>
> So I find bridging the zeromq and CAF world would be beneficial. What I am thinking of now is this (correct me if there are simpler ways):
>
> add something like:
>
> void publish(caf::actor whom, std::string const& endpoint)
>
> which basically extends the current actor publish to a zeromq (pub) endpoint, like "tcp://*5555".
>
> also at the other end, add a
>
> actor remote_actor(const std::string& endpoint)
>
> which spawns a broker to a zeromq (sub) endpoint, like "tcp://
127.0.0.1:5555",
>
> I am still struggling to understand how to fill the gap between the CAF and zeromq world. So the solution can be totally open, maybe even just use simple bridge actors to do message transfer.
>
> Any thoughts/ideas would be very appreciated.
CAF has groups to deal with pub/sub communication patterns. So my first suggestion would be to have a look at group modules. An API for your actors would look something along the lines of this: `self->join(group::get("0mq", "tcp://*5555"));`.
You need to implement the interface abstract_group::module. The three member functions you need to worry about are "subscribe", "unsubscribe", and "enqueue". The "enqueue" function is called whenever an actors sends something to the group. The other two functions should be self-explanatory.
I should be rather straightforward to wrap 0mq in a group module. There's one caveat, though: if you receive a message via 0mq, you'll most likely have to map the sender of each message to invalid_actor, unless you couple 0mq with some on-the-fly connection broker to be able to create valid proxies (at which point you would have to deal with CAF's middleman and basp_broker). As long as you don't need to reply to published messages, you'll be fine. :)
Dominik