zmq-exercise
v0.3.0
Published
Console app to exercise core ZMQ components
Downloads
5
Readme
ZMQ Exercise App
A console application to exercise core ZMQ components with three modes:
- Receiver Mode: Uses
zmq_message_receiverto receive pings and respond with pongs - Sender Mode: Uses
zmq_actor_senderto send pings - Connector Mode: Uses
zmq_actor_connectorto send Ping and get a Pong (request-response pattern)
Installation
# Install dependencies
npm installUsage
The application has three modes of operation:
Receiver Mode
Starts a receiver that listens for ping messages and responds with pong messages.
npm run receiverOptions:
--name <name>: Name of the receiver actor (default: "ping-pong-receiver")
Sender Mode
Sends ping messages to a specified target.
npm run senderOptions:
--target <target>: Target actor name (default: "ping-pong-receiver")--count <count>: Number of messages to send (default: 10)--interval <interval>: Interval between messages in ms (default: 1000)
Connector Mode
Sends Ping messages and waits for Pong responses using the request-response pattern.
npm run connectorOptions:
--target <target>: Target actor name (default: "ping-pong-receiver")--count <count>: Number of messages to send (default: 5)--timeout <timeout>: Timeout for responses in ms (default: 5000)
Testing the Application
To test the application, you need to run at least two instances in different terminals:
From the app directory
Start the receiver in one terminal:
cd apps/zmq-exercise && npm run receiverIn another terminal, run either the sender or connector:
cd apps/zmq-exercise && npm run sender # or cd apps/zmq-exercise && npm run connector
From the root directory (recommended)
Start the receiver in one terminal:
npm run zrIn another terminal, run either the sender or connector:
npm run zs # or npm run zc
Current Status
- Receiver Mode: Working - listens for both text and Protobuf Ping messages and responds accordingly
- Sender Mode: Working - sends Protobuf Ping messages to the specified target
- Connector Mode: Partially working - sends Ping messages but may not receive Pong responses due to request-response routing issues
Implementation Details
The application demonstrates three core ZMQ components:
- ZmqMessageReceiver: Used in receiver mode to listen for incoming messages
- ZMQActorSender: Used in sender mode to send one-way messages
- ZMQActorConnector: Used in connector mode for request-response communication
All three modes use Protocol Buffers for message serialization, specifically the Ping and Pong message types defined in the core package.
