SocketMQ
Lightweight messaging library for node & browser.
Messaging Types
SocketMQ supports req/rep
and pub/sub
messaging patterns. Messaging pattern is high level concept of how messages should be handled on sending and receiving. It's client/server & transport agnostic
which means you can use all 4 types of messaging pattern no matter you are connected to a server or being connected from a client with any of the transports supported.
Request/Response
Each request
will be sent to one
connected client/server and wait for response
(round-robin scheduler).
// example/rep.jsvar socketmq = ; var smq = socketmq; smq; var event = "hello"; // or you can call it topic or channel. smq; smq;
// example/req.jsvar socketmq = ; var smq = socketmq; smq; ; smq;
Publish/Subscribe
A pub
message will be distributed to all client/server connected and no response will be sent back. It's a fire and forget messaging pattern. Pub messages could be received by subscribing to the publishing topic.
// example/pub.jsvar socketmq = ; var smq = socketmq; smq;
// example/sub.jsvar socketmq = ; var smq = socketmq; smq; smq;
Using tags
SocketMQ can tag the streams and send messages to streams with specific tags.
var socketmq = ; var tcpUri = "tcp://127.0.0.1:6363";var smq = socketmq; var tlsUri = "tls://127.0.0.1:46363";smq; // Then send messages using `reqTag` of `pubTag` // `req` message only to server with `tcp` tagsmq; // `pub` message only to server with `tls` tagsmq;