How to send RT message with headers

Hi @Chad_Wyatt

When using the Send RT Channel Command I have tried to change the channel but it doesn’t work.

it should not, because sending command is just designed for exchanging commands between different clients, it means client1 send a command and client2, client3, clientX receive the command, of course if they were subscribed for that

If I want to send messages for different purposes how can I send via a different channel

just send messages to different channels

Regards, Vlad

Thanks Vladimir…

So I have tried different channels but it only works when it is set to default

Is there a specific format for defining channels ie ‘channel-1’ ?

Screen Shot 2022-10-13 at 8.56.06 pm

I have tried this but I get nothing, and infact on the send side it doesn’t run any logic after the sent RT command action

I have also tried the Pub/Sub listeners and I can’t get them to work at all.

Screen Shot 2022-10-13 at 8.58.50 pm

Note: I tried the Pub/Sub “Publish Action” without the ’ in the create object

does this ’ channel-1 ’ channel exist?

Right, I have to create the channel :person_facepalming:

could you please provide a page where we can try it?

one minute

1 Like

https://elatedtwist.backendless.app/api/files/ui-builder/containers/default/index.html?page=testrecieve

https://elatedtwist.backendless.app/api/files/ui-builder/containers/default/index.html?page=test2

I have an example of both Pub/Sub and the RT Command

Any ideas?

try to change header-x to headerX

commands seems like work

Still couldn’t see command working but I got Pub/Sub working with your recommendation above…

This will suit my purpose. Is there any difference in speed or volume Pub/Sub vs Command??

Can these messages be sent from a codebase outside of Backendless?

how do you check it?

I assume there is no difference

what do you mean? could you please provide an example

We have some python code running on a machine outside of backendless doing some object tracking and we want to send that data to the backendless. Currently we are using the api to send that to the database, from there we are running a timer from the frontend to poll the backend every second to get that data from the DB to the frontend. It’s rather inefficient.

It also fills up the DB with un needed data

I see,

well, for sending PUB-Sub messages there is a REST API General API - Backendless REST API Documentation

but with Commands, it’s a little bit complicated because it uses a different approach through sockets and to implement it you will need to replicate the client SDK RT-Client/scope-connector.js at master · Backendless/RT-Client · GitHub

Pub/Sub will be fine… I’ll get my code developer to look at those docs tomorrow. Thank you again!

Sorry I have one more question, can I run a Pub/Sub listener in the backend. I see the options are available but if I start a listener in an API call will it persists after the api call has returned?

no, once tasks are completed the worker will be removed.
using RT Listeners in the CloudCode can make sense only for fast notifications, for instance,

  • you subscribe to a channel X command and create a promise which will be resolved only when you receive an X command
  • then you send a Y command to the channel
  • if someone responds to you in a few seconds the promise will be resolved, but if it takes more time the cloud code worker will be destroyed by timeout