5

I'm implementing a messaging system where external programs called agents are able to communicate via ZeroMq producers. So, every time an event of interest occurs, agent sends a message to ZeroMq.

I'm interested in implementing this using pipeline pattern.

I found some examples (Ventilator-Worker-Results Manager), but Ventilator component creates an endpoint for accepting connections from the worker, and then sends all messages in batch.

My scenario is quite different. The "agent" connects every time an event is needed to be send - it doesn't wait for connections from the workers, so I'm wondering if this is possible? Also, the important fact is that messages have to be processed in order they were sent.

mac
  • 42,153
  • 26
  • 121
  • 131
Nedo
  • 627
  • 1
  • 10
  • 20

2 Answers2

2

You shoud mix the patterns to achieve your solution. I think it should be an specialized broker which instantiates REP agent collectors for real REQ agents. Those agent collectors should take care of ordering before communicate with the system.

Carlo Pires
  • 4,606
  • 7
  • 32
  • 32
  • This could be a nice solution, except I don't need bidirectional communcation here. The agent doesn't need to know if message were delivered to the broker - it just has to send it. – Nedo Nov 22 '11 at 09:39
  • I'm not sure, but [AFAIK](http://en.wiktionary.org/wiki/AFAIK), there is no notion of unidirecional sockets in ZeroMQ. If your REQ agents does need to keep connected with the broker, just close the socket each time an event is sent. – Carlo Pires Nov 26 '11 at 22:14
1

REQ-REP is when you want a round trip. Sounds like you want a PUB-SUB. Set up a SUB with a bind at a well-known port, then have the clients connect to that port and issue a PUB.

Randal Schwartz
  • 39,428
  • 4
  • 43
  • 70