Hi ,
i am facing some problem using simple message queue . i have placed this node ahead of azure iot hub .as when the messages received it will get buffered into queue and when i send trigger command from PLC Queue will be triggered to unload one message and the values in message will be pushed into plc tags one by one. it is working fine .but assume i have 50 messages in queue but when i restart the node red,messages in the queue getting erased .how to solve this issue?i want the messages to be stored even though i deploy the changes or node red restarts.
One good option is to store the values in context. Please refer to this link
i think i cannot store the messages which is in the queue node to context .i aware of context it could allow me to store the the variables not the entire payload . my messages in queue will be something like below.like this many messages will get stored in the queue node .how to make a queue node as retentive is my problem
{"message":{"binId":"BPTC02-37-1-4-2","commandType":2,"sRequestId":"09440af3-c48e-4e6a-9607-eef60f9f12e2","rRequestId":"02daf8e3-b282-4010-9575-4f53b40104e2","toX":2,"toY":2,"toZ":1,"fromX":0,"fromY":0,"fromZ":0},"timestamp":"2023-02-06T12:01:34.993Z"}
You might like to look at node-red-contrib-queue-gate which has the ability save the queue in file context, which is restored on restart.
Alternatively this flow also has that ability, and in addition can automatically retry failed messages if there is a problem sending the message to azure. Guaranteed delivery of data (upload, email etc) across a network (flow) - Node-RED
i tried this but when i restart the node-red all the messages in queue is getting erased .did you tried this before ? here is demo script i have used
[{"id":"a46ee04e.b1a9b8","type":"inject","z":"e5c32195.7ce7b8","name":"open","topic":"control","payload":"OPEN","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":80,"wires":[["c54e919c.18d7f"]]},{"id":"c54e919c.18d7f","type":"q-gate","z":"e5c32195.7ce7b8","name":"q-gate demo","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"peek","dropCmd":"drop","statusCmd":"status","maxQueueLength":"0","keepNewest":false,"qToggle":false,"persist":false,"x":410,"y":300,"wires":[["d2740316.7035c"]]},{"id":"c04db5ad.da76b8","type":"inject","z":"e5c32195.7ce7b8","name":"input","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":300,"wires":[["c54e919c.18d7f"]]},{"id":"287fae2e.cb245a","type":"inject","z":"e5c32195.7ce7b8","name":"toggle","topic":"control","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":160,"wires":[["c54e919c.18d7f"]]},{"id":"8fd8943b.e60c28","type":"inject","z":"e5c32195.7ce7b8","name":"close","topic":"control","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":120,"wires":[["c54e919c.18d7f"]]},{"id":"44541499.4ac23c","type":"inject","z":"e5c32195.7ce7b8","name":"default","topic":"control","payload":"default","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":200,"wires":[["c54e919c.18d7f"]]},{"id":"92b01a9d.669a58","type":"inject","z":"e5c32195.7ce7b8","name":"queue","topic":"control","payload":"queue","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":360,"wires":[["c54e919c.18d7f"]]},{"id":"5f8708d.abc59f8","type":"inject","z":"e5c32195.7ce7b8","name":"flush","topic":"control","payload":"flush","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":440,"wires":[["c54e919c.18d7f"]]},{"id":"fb8c7d0f.40eec","type":"inject","z":"e5c32195.7ce7b8","name":"trigger","topic":"control","payload":"trigger","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":400,"wires":[["c54e919c.18d7f"]]},{"id":"b7688480.6338","type":"inject","z":"e5c32195.7ce7b8","name":"reset","topic":"control","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":480,"wires":[["c54e919c.18d7f"]]},{"id":"44127021.988758","type":"inject","z":"e5c32195.7ce7b8","name":"peek","topic":"control","payload":"peek","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":520,"wires":[["c54e919c.18d7f"]]},{"id":"cc39c2df.44d0b8","type":"inject","z":"e5c32195.7ce7b8","name":"drop","topic":"control","payload":"drop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":560,"wires":[["c54e919c.18d7f"]]},{"id":"a94f3db7.55ae18","type":"inject","z":"e5c32195.7ce7b8","name":"status","topic":"control","payload":"status","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":240,"wires":[["c54e919c.18d7f"]]},{"id":"d2740316.7035c","type":"debug","z":"e5c32195.7ce7b8","name":"output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":570,"y":300,"wires":},{"id":"ae120d0f.ade318","type":"status","z":"e5c32195.7ce7b8","name":"q-gate status","scope":null,"x":410,"y":360,"wires":[["ea4d90f9.61a5b"]]},{"id":"ea4d90f9.61a5b","type":"debug","z":"e5c32195.7ce7b8","name":"status text","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"status.text","targetType":"msg","x":570,"y":360,"wires":}]
Unfortunately your flow is not importable. In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```
)
```
code goes here
```
You can edit and correct your post by clicking the pencil icon.
See this post for more details - How to share code or flow json
Did you tell the node to persist the queue, and configure file based context storage?
yes exactly
Show us how you have configured the node please. Also stop node red and start it again in a terminal window and copy/paste the startup log here.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.