How can I know, to which topic the arrived message belongs? - mqtt

I am developing an App and I am using MQTT protocol supported by Paho library.
I am subscribing to 10 topics, and there will be a messgae(s) published for one at least one topic. now, when I get notified about the arrival of a new messae, how can i know to which topic it belongs?
Update:

The object that you get when the message arrives should have a destination field which will contain the topic.

Related

Send a downlink message to TTN via thingsboard

I have integrated thingsboard and ttn to view uplink messages and creating dashboards. I'm interested in sending downlink messages as well. The examples I read ,take input from the uplink and add it as a payload field to the downlink and trigger the message by some change in attributes.
I want to send a custom payload (6 bytes) every hour and also change it based on user input.
Any help is appreciated.
Sorry for silly questions, newbie here...
Cheers

AWS Iot no activity logged

I am trying to find the connected devices and according to the forums and was advised to subscribe to "$aws/events/presence/+".
I have created two clients where one subscribes to the "$aws/events/presence/+" topic and the other one sends the connect command.
I could not see any activity under the tab.
Could you please help me to resolve this?
There is a subtopic to the presence topic that you need to consider by either adding the subtopic or using the multi-level topic wildcard (# instead of +). This means you need to subscribe to $aws/events/presence/connected/+ (or $aws/events/presence/# to monitor both connections and disconnections).
This accounts for the connected and disconnected subtopics on the reserved topics $aws/events/presence/connected/clientId and $aws/events/presence/disconnected/clientId.

Would solace topic be created only if it has an active subscriber?

I am not an expert on Solace, so apologies if my question is a primitive.
I have inherited a code base that I am looking to get to know more. It uses solace for messaging purposes. I see that the application publishes messages to a topic.
When I look up for this topic in solace UI I dont see the topic under the VPN.
Would topics in solace be created only if there are active subscribers?
I checked the logs of my application and they don't error out for the absence of the topic? What happens in case point 1 is true, and my application tries to send a message to solace when the topic hasnt been created.
I am using SolAdmin 7.1.1.158, is there way I can see my topic even if it does not have an active subscriber? Should that matter?
Thanks
I believe that you are confused about what is a topic.
Think of a topic as a concept of the publish-subscribe (pub/sub)
architectural pattern. They are used to route data or events (in the
form of messages) between distributed applications, often using a
message broker or an event broker.
Solace has a very detailed description of how topics work at https://solace.com/blog/solace-topics-vs-kafka-topics/.
Do note that topics are not the same as topic-endpoints.
Would topics in solace be created only if there are active subscribers?
Topics are only concepts and can't really be "created".
It is part of a message and used for routing messages. A application can also subscribe to a topic to receive messages that are published on a matching topic.
I checked the logs of my application and they don't error out for the absence of the topic? What happens in case point 1 is true, and my application tries to send a message to solace when the topic hasnt been created.
Publishers and consumers are decoupled when using the message broker.
When there are no subscribers to a topic, messages will be discarded and the "no subscription match" statistics and logs will increment.
If the publisher is sending guaranteed messages, you can enable the "Reject Msg To Sender On No Subscription Match" flag on it's client-profile to receive an negative acknowledgement when this occurs.
I am using SolAdmin 7.1.1.158, is there way I can see my topic even if it does not have an active subscriber? Should that matter?
Go to "Logging & Diagnostics" tab and select the "No Subscription Match Logs" view to take a look at the most recent messages that were dropped because there are no subscribers.

In MQTT, can i send a message to single client? Or only in a topic?

I have an application using MQTT, with clients connected on various topics, however, I have the need to send a message only to a client, not to an entire topic. Is that possible?
No, MQTT is a pub/sub protocol, messages are published on topics and there may be 0 to many subscribers to that topic
The closest you can do is pick a topic that you know only the client you want will be subscribed to.

How to know the topic(s) i am currently subscribed to?

I am using Paho MQTT library, but I do not know how to know if i am currently subscribed to a certain topic so that, no to subscribe to it again.
is there any way to know if a specific topic i am subscribed to it or not??
No, you have to explicitly keep track of what you subscribed to yourself.

Resources