# Stuck with message properties. \`q-gate\` node

**URL:** <https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203>\
**Category:** General\
**Created:** [24 November 2021 08:16 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203 "2021-11-24T08:16:10Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [24 November 2021 08:16 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/1 "2021-11-24T08:16:10Z")

</div>

This bit of code is working.

```auto
[{"id":"3c80536c.fdeb74","type":"q-gate","z":"f9420cde.5b8bb8","name":"","controlTopic":"CONTROL","defaultState":"queueing","openCmd":"Go","closeCmd":"Stop","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"50","keepNewest":true,"qToggle":false,"persist":false,"x":1080,"y":1690,"wires":[["6c96a140.9725d8"]]},{"id":"6c96a140.9725d8","type":"switch","z":"f9420cde.5b8bb8","name":"Last","property":"_queueCount","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1210,"y":1690,"wires":[["e6d3baca.8b0b38"],["160988d8.e2947f"]]},{"id":"160988d8.e2947f","type":"template","z":"f9420cde.5b8bb8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}} (Last)","output":"str","x":1220,"y":1730,"wires":[["e6d3baca.8b0b38"]]}]

```

My take on it is that the _gate_ queues messages.  
They are spat out on command and there is a _property_ `msg._queueCount`  
When that gets to `0` the message is formatted to have the word `LAST` in it so I know I have read all the messages.

That's the idea.

Version 1.5.2.  
(Both machines)

I want to do that on another machine.  
I'm building a test bit for now.

I'm not seeing that _property_ like with the other one.

Why not?

 ![Screenshot from 2021-11-24 19-14-54](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/38518a63e470f53bebdf50d50db686c3952adefa.png)

---

<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:** [24 November 2021 10:13 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/2 "2021-11-24T10:13:54Z")

</div>

You have not posted a full working flow for us to try.

Make sure that flow works on one system and not the other.

Personally if I want to know when the queue is empty I use the status rather than an undocumented feature. Also it is always a good idea to make sure you are using the latest version of nodes before querying behaviour in case the issue is already fixed.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [24 November 2021 19:38 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/3 "2021-11-24T19:38:11Z")

</div>

Correct: I haven't posted a _full working flow_.  
I posted the part that does that which I am asking.

Here is a slightly bigger part which has all the nodes needed to see it.

There are GUI nodes, so be prepared for them.

```auto
[{"id":"e6d3baca.8b0b38","type":"ui_text","z":"f9420cde.5b8bb8","group":"e48399e0.8415c","order":3,"width":"10","height":"4","name":"Flow error","label":"","format":"{{msg.payload}}","layout":"row-spread","x":1604,"y":1690,"wires":[]},{"id":"6c96a140.9725d8","type":"switch","z":"f9420cde.5b8bb8","name":"Last","property":"_queueCount","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1210,"y":1690,"wires":[["e6d3baca.8b0b38"],["160988d8.e2947f"]]},{"id":"160988d8.e2947f","type":"template","z":"f9420cde.5b8bb8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}} (Last)","output":"str","x":1220,"y":1730,"wires":[["e6d3baca.8b0b38"]]},{"id":"e72b1b4b.639ec8","type":"inject","z":"f9420cde.5b8bb8","name":"Next","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"CONTROL","payload":"trigger","payloadType":"str","x":1080,"y":1610,"wires":[["9dde0c69.114468"]],"icon":"node-red/trigger.svg"},{"id":"bdb9721b.575c4","type":"inject","z":"f9420cde.5b8bb8","name":"Wipe","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":" ","payloadType":"str","x":1080,"y":1650,"wires":[["3148dfa8.a094e"]],"icon":"font-awesome/fa-eject"},{"id":"3c80536c.fdeb74","type":"q-gate","z":"f9420cde.5b8bb8","name":"","controlTopic":"CONTROL","defaultState":"queueing","openCmd":"Go","closeCmd":"Stop","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"50","keepNewest":true,"qToggle":false,"persist":false,"x":1080,"y":1690,"wires":[["6c96a140.9725d8"]]},{"id":"9dde0c69.114468","type":"ui_button","z":"f9420cde.5b8bb8","name":"Next ","group":"e48399e0.8415c","order":4,"width":"2","height":"1","passthru":true,"label":"Next","tooltip":"","color":"","bgcolor":"lime","icon":"","payload":"trigger","payloadType":"str","topic":"CONTROL","topicType":"str","x":1210,"y":1610,"wires":[["3c80536c.fdeb74"]]},{"id":"3148dfa8.a094e","type":"ui_button","z":"f9420cde.5b8bb8","name":"","group":"e48399e0.8415c","order":5,"width":"2","height":"1","passthru":true,"label":"Wipe","tooltip":"","color":"","bgcolor":"red","icon":"","payload":" ","payloadType":"str","topic":"","topicType":"str","x":1210,"y":1650,"wires":[["e6d3baca.8b0b38"]]},{"id":"e48399e0.8415c","type":"ui_group","name":"Flow error display","tab":"48f5e285.67a4c4","order":1,"disp":true,"width":"11","collapse":false},{"id":"48f5e285.67a4c4","type":"ui_tab","name":"ALARMS","icon":"mi-notification_important","order":5,"disabled":false,"hidden":false}]

```

Just send any message into the `q-gate` then press the `Next` button/node.

There is still a lot of code which I haven't posted. It isn't important to get the result.  
But here is a full _go to woe_ of things happening.

All things are good:

 ![Screenshot from 2021-11-25 06-28-16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a5d02590d169e6636cc712eaf28f50fb60a8470d.png)

An error is detected. I see _who_ has it and am prompted to look at it.  
I press the `NEXT` button and see this.

 ![Screenshot from 2021-11-25 06-28-34](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33b9a541bbcd8398788661a2a7261fa23412a9de.png)

As there is only `1` error, you can clearly see the `(Last)` message appended to the message.

 ![Screenshot from 2021-11-25 06-28-38](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e6e09d9b61b9ee1696b8641059d2d6985e256fbd.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [24 November 2021 20:03 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/4 "2021-11-24T20:03:42Z")

</div>

> [@Colin](#):
>
> Also it is always a good idea to make sure you are using the latest version of nodes before querying behaviour in case the issue is already fixed.

Both machines have the same version, so all things being equal if it works on one: it should work on the other.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [24 November 2021 20:49 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/5 "2021-11-24T20:49:15Z")

</div>

Ok, update:

Now it isn't working. There is now no longer a `msg._queueCount`

Sorry. I'll have to attack this from a different perspective.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [25 November 2021 14:55 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/6 "2021-11-25T14:55:28Z")

</div>

Andrew, I am the principal author of the `q-gate` node, and @Colin is a contributor. We both make an effort to assure that the code is as bug-free as possible and that it performs as users expect. I would not like to see your experience discourage others from using the node or give the impression that there are issues with it that we have not tried to find and correct.

Since `msg._queueCount` is not a property we use or define in `q-gate`, I have to assume that you have created it elsewhere in your flow. If you continue to believe that there is a difficulty in this node that needs attention, please give more specifics here or raise an issue on GitHub.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 November 2021 22:53 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/7 "2021-11-25T22:53:04Z")

</div>

There must be something wrong with how I am asking.

I'm not attacking anyone or saying it (the node/code) is faulty.

I tried searching for where I was told to use `msg_queueCount` but can't find it.  
I am 99% certain I asked a while back and was pointed in that direction.

It is too technical for me to have contrived.

Now - of course (and typically) it isn't working/doesn't exist in the message.

I have seen my previous posts when I was asking about something and you can clearly see that _property_ exists/existed.

Not to worry. I pfaffed around with a couple of other nodes and got what that was doing working and so have sort of moved on.

Not to lay blame or say "it wasn't me" could you have a quick search (if not for my benefit) and see if you can find where I was told that property (`msg_queueCount`) exists.

The thread did have `q-gate` in it. Be it with out without the `-`.

I may try again myself but when I try, I just go around and around in circles.

Ok, it is more than a year ago, but here is a screen shot which has that property existing.

I'm not going to further edit the screen shot, but look on the right at the bottom of the big red circle. Bottom line.  
And it is straight out of the `q-gate` node.

 ![Screenshot from 2020-05-13 10-25-13](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8e98d3ccd27b47989525e9a7377c7e75aa624703.png)

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [26 November 2021 03:47 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/8 "2021-11-26T03:47:30Z")

</div>

> [@Trying\_to\_learn](#):
>
> I'm not attacking anyone or saying it (the node/code) is faulty.

I hope I didn't sound defensive. When you mention the node in the subject of your post and say "Now it isn't working," one has to suspect that you are not happy with it.

A little detective work convinces me that the screenshot above (2020-05-13 10-24-13) does not show the `q-gate` node but rather [node-red-contrib-simple-message-queue](https://flows.nodered.org/node/node-red-contrib-simple-message-queue). This node uses message properties `ttl`, `_queuetimestamp`, and `_queueCount`, as seen in the screenshot. I hope this information helps you troubleshoot your flows.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 November 2021 04:04 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/9 "2021-11-26T04:04:15Z")

</div>

Ah!

Thanks very much.

I know I should have done more research before it got to this... 😉

The **Now it isn't working** was more one of confusion than blame assignation.  
I didn't _get_ why it worked and now didn't.

You are right. At some stage I had _the competition's_ node. (ie: the one you mentioned now)  
For reasons I can't remember just now there was a time when I had it and your plane `gate` node. Then I saw you had the `q-gate` node and rather than having the other one I migrated them all to your node.

And if it was the previous node that did it and not yours: it would explain a lot.

I am sincerely sorry I didn't work that out myself.

(But it would be nice if that was an option in your node) 😉

Yes, ITMT I have worked out a work around - as suggested by @Colin - I think. The `status` node. But that needs 2 nodes and a bit of message crunching to get the result.

Again: Thanks.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [26 November 2021 04:40 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/10 "2021-11-26T04:40:26Z")

</div>

Glad that's sorted.

> [@Trying\_to\_learn](#):
>
> it would be nice if that was an option in your node

I assume you are referring to the `_queueCount` property. There are two reasons I have not gone in that direction, one "philosophical" and one practical. I have made it a principle in both the `gate` and `q-gate` nodes not to modify the user's messages in any way as they pass through. Control and reporting of the state of the node is handled entirely "out-of-band." This prevents the user from relying on any particular modifications of the messages that might be affected by bugs in the code or misinterpretation downstream in the flow. Your issue seems to be a subtle case of that kind. From a practical point of view, a message property indicating the queue size **when the message was sent** seems less useful than a status showing the length **now**. The possibility of dropping messages from the queue without sending them or having new messages arrive before the dequeued message can be processed also complicates matters. In short, I think your "work-around" is actually the right answer.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 November 2021 05:05 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/11 "2021-11-26T05:05:07Z")

</div>

Fair enough.

And I respect that. I'll have to work out my _work around_ with the other nodes.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 November 2021 05:27 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/12 "2021-11-26T05:27:20Z")

</div>

(Sorry......)

Just _Spit balling_......

How about a second output that gives telemetry data like the queue count?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 November 2021 08:22 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/13 "2021-11-26T08:22:05Z")

</div>

That is what the status is for.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 November 2021 08:27 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/14 "2021-11-26T08:27:09Z")

</div>

Yes, but that is not at a level where the information can be used at/in the flow.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 November 2021 11:35 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/15 "2021-11-26T11:35:14Z")

</div>

which is what the status node is for

---

<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:** [26 November 2021 11:52 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/16 "2021-11-26T11:52:54Z")

</div>

Presumably you have worked out that you can use something like `Number(split(":")[1])` to get the count.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [26 November 2021 17:38 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/17 "2021-11-26T17:38:55Z")

</div>

> [@Trying\_to\_learn](#):
>
> How about a second output that gives telemetry data like the queue count?

That would be possible, but there is already work underway to use an optional second output for [other purposes](https://github.com/drmibell/node-red-contrib-queue-gate/pull/19). If you can get by with only the `queueing` mode of the gate, you might try [node-red-contrib-multiple-queue](https://flows.nodered.org/node/node-red-contrib-multiple-queue). It has an optional second output that provides a detailed status object in response to a `status` command.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 November 2021 20:49 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/18 "2021-11-26T20:49:22Z")

</div>

Yes, ok.

@Colin has better way than I was going. Though that was what I was doing, mine was the longer way to get it. Colin's way is better/quicker/neater.

Ok. No problems. I didn't want to have both nodes installed only because it confuses me. (See this thread)

Keeping only one type of node is neater.

---

<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:** [10 December 2021 20:50 UTC](https://discourse.nodered.org/t/stuck-with-message-properties-q-gate-node/54203/19 "2021-12-10T20:50:21Z")

</div>

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