In the last post I shown a Publish/Subscribe communication pattern with ZeroMQ and its C# binding library showing an asynchronous way in dispatching messages through many clients. Well this is not the only way we have. Another strategy is to have a listener and many clients sending messages to it and awaiting for response. All this is achieved by changing the Socket type we create.
You can find the code for this example and the previous one here.
Here the code for the client:
After the connect, we start a loop sending a message to the server, and receiving the reply from it.
Here is the server:
Please note the Bind() function, this is the line saying server is listening for calls. Code contains a test, proving messages are handled in sequence even if many client are sending messages in concurrency. This is part of the key point of this communication pattern:
Request/Reply key Point:
So there is a sort of state on the cannel, and we have some feedback about the fact the recipient handle our messages. If you heard about the Saga pattern you probably guess when this scenario can be used.
a@href@title, b, strike, strong
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.