# Identifying the duplicate value in queue and dropping that particular value out of queue

**URL:** https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217
**Category:** General
**Tags:** database
**Created:** [15 February 2023 07:03 UTC](https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217 "2023-02-15T07:03:17Z")
**Posts on this page:** 7
**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: [15 February 2023 07:03 UTC](https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217/1 "2023-02-15T07:03:18Z")

</div>

is there any ways to identifying the duplicate messages in queue and drop that duplicate message of queue . i have some messages from azure iot hub in JSON format (attached the payload below) .i have kept simple queue node ahead of azure iot hub node .it will queue all messages and when and all i get signal from PLC this messages will be triggered from queue and send to plc tags . i am having same messages repeated twice sometimes but there are not stored one after other .is there any way to identify those duplicates and delete them from queue

---

<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 07:17 UTC](https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217/2 "2023-02-15T07:17:56Z")

</div>

Possibly you can use a Filter node to stop then going into the queue.

---

<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 09:12 UTC](https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217/3 "2023-02-15T09:12:12Z")

</div>

this is the json message i get from azure iot hub . like this ill receive 100 messages with different "binId" and other parameter .there are some cases same messages is getting received after some messages .i.e assume the below is my first message in queue and i have 49 different messages in queue but 50th message in queue is duplicate of 1st message i should kick this 50th message .how can i take one message and compare with other message in queue and if not duplicate then load to queue  
{"binId":"BPTC02-37-1-5-1","commandType":2,"sRequestId":"fbb79de2-bc7b-40a3-b5e1-6095627c19af","rRequestId":"81902f1c-be22-4ff2-8d2a-f0e1ba8a81ab","toX":1,"toY":1,"toZ":1,"fromX":0,"fromY":0,"fromZ":0}

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [15 February 2023 11:02 UTC](https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217/4 "2023-02-15T11:02:37Z")

</div>

> [@gopinath.m](#):
>
> I receive 100 messages with different "binId" and other parameter.  
> ... but 50th message in queue is duplicate of 1st message i should kick this 50th message

Do you mean that only one message should be allowed in the queue for each binId?

There is node-red-contrib-multiple-queue which may do what you want.  
You can configure it to maintain a seperate queue for each msg.binId and allow only one entry per queue.  
I don't think you can trigger the oldest queued message regardless of binId though.

---

<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: [15 February 2023 14:26 UTC](https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217/5 "2023-02-15T14:26:50Z")

</div>

> [@gopinath.m](#):
>
> is there any ways to identifying the duplicate messages in queue and drop that duplicate message

I have written several nodes for message queueing and scheduling (not all of them published), and I might be able to help if I understood your issue better. I am assuming a few things, so correct me if I am wrong.

1. Two messages are "duplicates" if every property, not just the `binId` is identical.
2. The difficulty is not with the size of the queue. A few hundred messages of the size you describe should not create a problem, and a few percent of duplicates will not matter.
3. When you say "send to plc tags," you mean that a message is sent from the queue to a PLC.
4. For some reason, you don't want the PLC to see duplicate messages. If this is the case, please explain why. Filtering needs to be done either before or after the queue, and if you want the PLC to **never** see a duplicate, you may have to do much more work than is done by the queue.

---

<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: [15 February 2023 14:29 UTC](https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217/6 "2023-02-15T14:29:14Z")

</div>

> [@jbudd](#):
>
> I don't think you can trigger the oldest queued message regardless of binId though.

That's correct, but IIRC you can send the oldest message from each queue at the same time by using the `trigger` command with the `Queue Selector` set to `All Queues`.

---

<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 14:29 UTC](https://discourse.nodered.org/t/identifying-the-duplicate-value-in-queue-and-dropping-that-particular-value-out-of-queue/75217/7 "2023-04-16T14:29:23Z")

</div>

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