I’m trying to learn more about NATS and I’m working through the python examples here and here I started with the command line and tested the Request-Response pattern using these commands.
#Terminal 1
nats reply greet.sue 'OK, I CAN HELP!!!'
18:42:54 Listening on "greet.sue" in group "NATS-RPLY-22"
18:42:56 [#0] Received on subject "greet.sue":
I need help!
#Terminal 2
nats reply greet.sue 'OK, I CAN HELP!!!'
18:42:54 Listening on "greet.sue" in group "NATS-RPLY-22"
18:42:56 [#0] Received on subject "greet.sue":
I need help!
#Terminal 3
nats request greet.sue 'I need help!'
18:42:56 Sending request on "greet.sue"
18:42:56 Received with rtt 834.292µs
OK, I CAN HELP!!!
This worked as per the documentation and the two reply
services respond in a kind of round-robin
way.
I now need the Python equivalents to continue my testing, but all of the examples are trying to be way to clever – i.e. they include both the request
and reply
logic in the same example (e.g. request-reply) which makes it much harder and confusing to understand what’s happening.
I can’t seem to find any simple examples that break out the Python logic into separate components that behave in the same way as the CLI commands. Can anybody help me out here please.