Is there a way of implementing the publish / subscribe pattern from the command line without using a server process? This need only work on one machine.
The main thing I want to avoid by not having a server process is having configure a machine to use these tools. I'm also quite keen on not having to deal with the possibility of my server process dying.|
This might look something like:
# client 1 subscribe name | while read line; do echo $line; done # client 2 subscribe name | while read line; do echo $line; done # server echo message | publish name
- POSIX ipc provides a serverless message queue and there are command-line clients for it (1) (2) (3). This could be used together with some sort of state storage to implement the above.
- ZMQ provides a protocol for pub / sub communication. There are command-line tools analogous to nc for using ZMQ, such as zmcat. These could be used to set up a minimal command-line pub/sub pattern with a server.
- Linux provides another IPC mechanism called named pipes (c.f. mkfifo). I don't know what the intended behaviour with multiple consumers is. But some initial experimentation suggests that each message is only received by one of the consumers