Backendless Support

Filtering duplicate messages when using pub/sub messaging with multiple topics


I am incorporating your pub/sub messaging system in an application that allows users to subscribe to multiple topics and post to multiple topics. The idea is that a user can send a message to multiple topics at once, which is not supported by Backendless. This is why I push a message for each selected topic separately. The problem is that each of these messages has a different UID, which makes it difficult to check for duplicate messages when user A pushes to multiple topics and user B is subscribed to more than one of those topics.

For example. User A pushes message 'I have arrived!' on channel 'default' and selects topic 'alerts' and 'warnings'. I have to push both messages separately, since Backendless doesn't provide an API to send a message to multiple topics at once. Now let's say that user B is subscribed to channel 'default' with topic 'alerts' and channel 'default' with topic 'warnings'. This means that user B will receive the same message twice, since he is subsribed to both channels.

Filtering out this duplicate message based on a UID is impossible, since both messages have a different UID. It would be possible to consider a message a duplicate when noticing that they have the same sender and data, but this would make it impossible for a user to send the exact same message twice.

What's the best way to tackle this problem?

Leave a Comment

Comments (2)


Hi Minimalistics,

Maybe you should change you approach to using Messaging service API.

You can create one topic (e.g. 'alerts') and make several subtopics (e.g. 'error', 'warnings', 'info' etc.), so your subscribers can filter messages by it (e.g. 'alerts.*' - all alerts, 'alerts.warnings' - only warning alerts).

Please, let us know if it helps you.

Regards, Ilya


Hey Ilya,

I'm afraid that this doesn't fit in my use-case. My case is an n:n example, it can't be reduced to an 1:n example. The alerts example was just to make it so you understand the setup. Users can send messages to multiple topics at once and can receive messages that are sent to multiple topics at once.

I guess I can send the published messages as a JSON object, so I can add a UID myself. I was just wondering if I overlooked some functionality of your API, but it seems that I didn't.