# Node-red-contrib-simple-message-queue

**URL:** <https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825>\
**Category:** Developing Nodes\
**Tags:** database\
**Created:** [7 February 2023 05:21 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825 "2023-02-07T05:21:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gopinath.m](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@gopinath.m](https://discourse.nodered.org/u/gopinath.m)\
**Post date:** [7 February 2023 05:21 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/1 "2023-02-07T05:21:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [7 February 2023 05:46 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/2 "2023-02-07T05:46:09Z")

</div>

One good option is to store the values in context. Please refer to [this](https://nodered.org/docs/user-guide/context) link

---

<div class="post-metadata">

**Author:** ![gopinath.m](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@gopinath.m](https://discourse.nodered.org/u/gopinath.m)\
**Post date:** [7 February 2023 05:51 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/3 "2023-02-07T05:51:09Z")

</div>

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"}

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 February 2023 10:46 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/4 "2023-02-07T10:46:57Z")

</div>

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](https://flows.nodered.org/flow/05e6d61f14ef6af763ec4cfd1049ab61)

---

<div class="post-metadata">

**Author:** ![gopinath.m](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@gopinath.m](https://discourse.nodered.org/u/gopinath.m)\
**Post date:** [9 February 2023 05:26 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/5 "2023-02-09T05:26:08Z")

</div>

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":}]

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 February 2023 16:42 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/6 "2023-02-09T16:42:35Z")

</div>

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 `````)

````auto
``` 
   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](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 February 2023 16:46 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/7 "2023-02-09T16:46:14Z")

</div>

Did you tell the node to persist the queue, and configure file based context storage?

---

<div class="post-metadata">

**Author:** ![gopinath.m](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@gopinath.m](https://discourse.nodered.org/u/gopinath.m)\
**Post date:** [15 February 2023 04:04 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/8 "2023-02-15T04:04:46Z")

</div>

yes exactly

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 February 2023 09:26 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/9 "2023-02-15T09:26:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 April 2023 09:26 UTC](https://discourse.nodered.org/t/node-red-contrib-simple-message-queue/74825/10 "2023-04-16T09:26:28Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
