Lightweight stream-oriented messaging library for node.
Lightweight stream oriented messaging library.
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 will be sent to
one connected client/server and wait for
response (round-robin scheduler).
// example/rep.jsvar socketmq = require'../'var smq = socketmqbind'tcp://127.0.0.1:6363'smqon'bind'console.log'rep bound'smqon'connect'console.log'new connection'smqreq'request from server' 'hello'console.logmsgsmqrep'hello'console.log'requested msg:' + msgreply'Hi ' + msg + ', world!'
// example/req.jsvar socketmq = require'socketmq'var smq = socketmqconnect'tcp://127.0.0.1:6363'smqon'connect'console.log'req connected to server'setIntervalsmqreq'hello' 'socketmq.req'console.log'replied msg:' + msg1000smqrep'request from server'console.log'request from server' msgreply'response from client'
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 = require'socketmq'var smq = socketmqconnect'tcp://0.0.0.0:6363'smqon'connect'console.log'pub connected';setIntervalsmqpub'pub.test' 'hello'1000
// example/sub.jsvar socketmq = require'socketmq'var smq = socketmqbind'tcp://127.0.0.1:6363'smqon'bind'console.log'sub bound'smqsub'pub.test'console.log'got pub message: ' + data