Redlink simple flow example 3

This is a simple single store with a producer and consumer on it.

The flow (on a per transaction basis) can preserve some data (or object) that is stored on the producer and not sent to the consumer, however it is returned back to the producer output when the consumer completes and returns its message reply.

Note that only msg.payload is sent, msg.topic is not sent to the consumer, this is due to msg.topic being used for control of the producer / consumer / stores.

[{"id":"4c6527ab.d816c","type":"tab","label":"A","disabled":false,"info":""},{"id":"2424bdb5.da803a","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"796184ae.9d810c","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":676,"y":308,"wires":[]},{"id":"5c6ad178.d10d1","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":661,"y":264,"wires":[]},{"id":"39a36fe3.f2a288","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":658.285888671875,"y":359.42852783203125,"wires":[]},{"id":"9fc54263.437da8","type":"inject","z":"4c6527ab.d816c","name":"SendMessage","topic":"","payload":"This is my test","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":194.71435546875,"y":93.42855834960938,"wires":[["73edf8aa.6b71a8","767fa925.d93398"]]},{"id":"73edf8aa.6b71a8","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":385,"y":98.42855834960938,"wires":[]},{"id":"767fa925.d93398","type":"function","z":"4c6527ab.d816c","name":"Payload = 0","func":"msg.payload=0;\nreturn msg;","outputs":1,"noerr":0,"x":237.5,"y":174.4285888671875,"wires":[["bdde971c.6e49f"]]},{"id":"bdde971c.6e49f","type":"function","z":"4c6527ab.d816c","name":"Inc Payload","func":"var msg1={};\nmsg1.payload=msg.payload+1;\nreturn msg1;","outputs":1,"noerr":0,"x":236.5,"y":216.42855834960938,"wires":[["7be9b429.b3823c","b8111fbb.655b58","d2896db3.2b9d7"]]},{"id":"b8111fbb.655b58","type":"delay","z":"4c6527ab.d816c","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"3","randomUnits":"seconds","drop":false,"x":229.5,"y":262.4285888671875,"wires":[["bdde971c.6e49f"]]},{"id":"7be9b429.b3823c","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":531,"y":215.4285888671875,"wires":[]},{"id":"94aa4046.96a25","type":"inject","z":"4c6527ab.d816c","name":"","topic":"listRegistrations","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":175,"y":380,"wires":[["57e55ac9.7c30f4"]]},{"id":"19d3efb9.029908","type":"debug","z":"4c6527ab.d816c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":488,"y":377,"wires":[]},{"id":"a2d02cb9.dc448","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":494,"y":417,"wires":[]},{"id":"e26e3cfd.2929d8","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":492,"y":462,"wires":[]},{"id":"9be4928d.b59888","type":"inject","z":"4c6527ab.d816c","name":"","topic":"listStore","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":164,"y":418,"wires":[["57e55ac9.7c30f4"]]},{"id":"34fd789b.9073d8","type":"inject","z":"4c6527ab.d816c","name":"","topic":"flushStore","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":165,"y":460,"wires":[["57e55ac9.7c30f4"]]},{"id":"e7fec544.cc381","type":"comment","z":"4c6527ab.d816c","name":"Click the debug to watch it run","info":"","x":655,"y":140,"wires":[]},{"id":"5b5beedc.79f35","type":"comment","z":"4c6527ab.d816c","name":"Click the SendMessage to start the loop from producer to consumer and back","info":"","x":316,"y":42,"wires":[]},{"id":"57e55ac9.7c30f4","type":"redlink store","z":"4c6527ab.d816c","listenAddress":"localhost","listenPort":"2101","peerAddress":"0.0.0.0","peerPort":443,"headers":[{"ip":"localhost","port":"2001"},{"ip":"localhost","port":"2002"}],"name":"A","meshName":"mesh0","notifyInterval":15,"oldStore":true,"showRegistration":true,"showDebug":true,"outputs":3,"x":349,"y":418,"wires":[["19d3efb9.029908"],["a2d02cb9.dc448"],["e26e3cfd.2929d8"]]},{"id":"b7a6cea9.70596","type":"redlink producer","z":"4c6527ab.d816c","name":"ProducerA","producerStoreName":"mesh0:A","producerConsumer":"DA","producerTTL":15,"producerETT":300,"priority":0,"timeout":-1,"sendOnly":false,"manualRead":false,"rateTypeSendReceive":"none","rateSendReceive":1,"rateUnitsSendReceive":"second","nbRateUnitsSendReceive":"","topic":"","cmd":"send","private":false,"ttl":null,"tba":null,"showDebug":false,"outputs":3,"x":511,"y":309,"wires":[["5c6ad178.d10d1"],["796184ae.9d810c"],["39a36fe3.f2a288"]]},{"id":"7bf5ce81.250168","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":657,"wires":[]},{"id":"c1ab0205.64b618","type":"function","z":"4c6527ab.d816c","name":"Return To Producer","func":"var msg1={};\nmsg1.payload= msg.payload;\nmsg1.redlinkMsgId = msg.redlinkMsgId;\nmsg1.redlinkProducerId=msg.redlinkProducerId;\nreturn msg1;","outputs":1,"noerr":0,"x":450.5,"y":522,"wires":[["a787c134.5275a8"]]},{"id":"8464e28d.66158","type":"inject","z":"4c6527ab.d816c","name":"ManualRead","topic":"read","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":189.5,"y":621,"wires":[["a787c134.5275a8"]]},{"id":"c4a32efc.fba828","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":566,"y":620,"wires":[]},{"id":"89416d9e.e9845","type":"debug","z":"4c6527ab.d816c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":571,"y":574,"wires":[]},{"id":"a787c134.5275a8","type":"redlink consumer","z":"4c6527ab.d816c","name":"DA","consumerMeshName":"mesh0","consumerStoreName":"A","intransit":"1","manualReadReceiveSend":false,"rateTypeReceiveSend":"none","rateReceiveSend":"25","rateUnitsReceiveSend":"second","nbRateUnitsReceiveSend":"1","topicReceiveSend":"","cmd":"read","showStatsReceiveSend":false,"statsFrequencyReceiveSend":0,"showDebugReceiveSend":false,"outputs":3,"x":401,"y":620,"wires":[["c1ab0205.64b618","89416d9e.e9845"],["c4a32efc.fba828"],["7bf5ce81.250168"]]},{"id":"d2896db3.2b9d7","type":"function","z":"4c6527ab.d816c","name":"Add some Preserved data / per message","func":"msg.preserved = \"Some preserved Data or object that is held by the producer and re-added to the reply msg on completion\";\nreturn msg;","outputs":1,"noerr":0,"x":243.5,"y":309,"wires":[["b7a6cea9.70596"]]}]

Flow Info

Created 6 years, 1 month ago
Updated 5 years, 10 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • comment (x2)
  • debug (x11)
  • delay (x1)
  • function (x4)
  • inject (x5)
Other

Tags

  • redlink
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option