I have to develop a message bus for processes to send, receive messages from each other. Currently, we are running on Linux with the view of porting to other platforms later.
For this, I am using ZeroMQ over TCP. The pattern is PUB-SUB with a forwarder. My bus runs as a separate process and all clients connect to SUB port to receive messages and PUB to send messages. Each process subscribes to messages by a unique tag. A send
call from a process sends messages to all. A receive
call will fetch that process the messages marked with the tag of that process. This is working fine.
Now I need to wrap the ZeroMQ stuff. My clients only need to supply a unique tag. I need to maintain a global list of tags vs. ZeroMQ context and sockets details. When a client say,
initialize_comms("name");
the bus needs to check if this name is unique, create ZeroMQ contexts and sockets. Similarly, if a client say receive("name");
the bus needs to fetch messages with that tag.
To summarize the problems I am facing;
- Is there anyway to achieve this using facilities provided by ZeroMQ?
- Is ZeroMQ the right tool for this, or should I look for something like nanomsg?
- Is PUB-SUB with forwarder the right pattern for this?
- Or, am I missing something here?