Search code examples
c++zeromqace

ZeroMQ with ACE Reactor


I have a legacy application that handles communication using the ACE Reactor. To improve reliability across temporary network partitions, I would like to use ZeroMQ, instead of TCP sockets, as the transport. ACE provides C++ wrappers for existing IPC mechanisms, but I want to provide a custom IPC mechanism that ACE can use. In my particular case I want to use zmq, but my question is more general and I am asking, how can I use a custom transport with ACE?


Solution

  • There are two ways to go about this.

    1. Derive a new family of IPC classes from ACE_SOCK or maybe ACE_IPC_SAP, depending on what ZeroMQ gives you for a model. Don’t forget the address class to match. This is a lot of work but may be worth it if you will reuse it in many places.
    2. Derive a handler for your use case from ACE_Event_Handler and include a member that is your ZeroMQ transfer object. Assuming you can get a selectable socket handle from the ZeroMQ object you can access it from the get_handle() hook and register it with the reactor. Then from your handle_input() et al callbacks do the message transfer. This is relatively quick and easy.