How to create topics?Is topic is creating from ui side?

Hi,
I implemented mqtt in my application.Now each user is creating a topic from ui side and the message is successfully published based on topic.Is this the correct way to create topics.Client itself is enter the topic?

Hi @Resma
Thank you for sharing your MQTT implementation experience and your enthusiasm for HiveMQ. Welcome to our community!

I’m delighted to learn that you’ve successfully integrated MQTT into your application, allowing each user to create topics directly from the user interface (UI). It’s a fantastic initiative, and I’d be excited to see screenshots of your app’s UI!

If I understand correctly, your inquiry pertains to whether it’s advisable to enable clients (users) to create topics through the UI for MQTT messaging. However, it’s important to note that, in MQTT, there isn’t a distinct action to “create a topic” as you might think. In MQTT, topics essentially come into existence when a subscription is made or a message is published to that topic. To better understand this concept, I recommend delving into the fundamentals of MQTT through resources such as our guide: “MQTT Essentials - Part 4: MQTT Publish, Subscribe, Unsubscribe” available here: MQTT Essentials - Part 4.

Should you have any further questions or if there’s anything specific you’d like to discuss regarding your MQTT implementation, please don’t hesitate to reach out. I’m here to assist!

Best regards,
Dasha from HiveMQ Team

if I give a hardcoded topic in my code then all the device run the same code base will receive the published message.But i dont want to get message in all the device I only want to get the data based on topic and client id.My doubt is that how we give topic for each user? Only possible way is to give manually enter the topic from UI?

In my scenerio i am using mqtt for getting logs of events handled in my sample application.I only want to get logs from specific device only.So i am bit confused.
From my understanding “topic” is the only way to access that.Is this right?

You’re correct that MQTT topics are the primary mechanism for filtering and routing messages to specific clients.

Consider the scenario with multiple devices:

  • device1 publishes its messages to the topic logs/device1
  • device2 publishes its messages to the topic logs/device2
  • device3 publishes its messages to the topic logs/device3 …and so forth.

Now, let’s delve into how an application can intelligently receive messages from these devices:

  • If the application seeks messages exclusively related to device1, it should subscribe to the topic logs/device1.
  • In a broader context, should the app desire messages from both device1 and device2, a subscription to topics logs/device1 and logs/device2 would be necessary.
  • For receiving messages from all devices, the application would need to subscribe to the topic logs/+. (Here, the + symbolizes an MQTT wildcard, representing a single level in the topic hierarchy: MQTT Wildcard)

This hierarchical approach to MQTT topics provides a structured and adaptable strategy for customizing message reception to precisely match the application’s requirements.

Should you require further assistance, please don’t hesitate to reach out.