Created
June 6, 2020 05:38
-
-
Save timothymugayi/27cb2a09ed6c390629e9798371125d9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Subscribers are created with ZMQ.SUB socket types. | |
# A zmq subscriber can connect to many publishers. | |
import sys | |
import zmq | |
port = "5556" | |
if len(sys.argv) > 1: | |
port = sys.argv[1] | |
int(port) | |
# Socket to talk to server | |
context = zmq.Context() | |
socket = context.socket(zmq.SUB) | |
print("Collecting updates from server...") | |
socket.connect("tcp://localhost:%s" % port) | |
# Subscribes to all topics you can selectively create multiple workers | |
# that would be responsible for reading from one or more predefined topics | |
# if you have used AWS SNS this is a simliar concept | |
socket.subscribe("") | |
while True: | |
# Receives a string format message | |
print(socket.recv()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment