BreedCheckerService is a ZeroMQ-based Python microservice that provides information about various cat and dog breeds. It listens on TCP port 5555 and responds to serialized requests using Python's pickle module.
This microservice accepts two types of requests:
request = {"class": 0}request = {"list": ""}All requests must be serialized using pickle and sent over a ZeroMQ REQ socket.
import zmq
import pickle
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
request = {"class": 0}
socket.send(pickle.dumps(request))request = {"list": ""}
socket.send(pickle.dumps(request))response = pickle.loads(socket.recv())
print(response)Expected output:
{
"species": "Cat",
"breed": "Abyssinian",
"description": "The Abyssinian is a medium-sized cat with a lean, muscular body and a short coat, known for being extremely active and playful.",
"link": "https://en.wikipedia.org/wiki/Abyssinian"
}The diagram below illustrates the interaction between the client and the BreedCheckerService microservice
- Python 3.x
- ZeroMQ (
pyzmqlibrary) picklelibrary (standard in Python)
pip install pyzmqpython BreedCheckerService.pyYou must write your own client code to interact with the microservice using the communication contract above. Do not rely on the test program provided.
- The microservice and client are decoupled and communicate only via ZeroMQ sockets.
- All data is serialized using pickle. Ensure both sides use compatible Python versions.
