Hi i need to read a message from a topic in HiveMqCloud
I have a SpringBoot app and my idea is that when I receive a message from a topic I want to take that message and insert into a database.
The problem is that when I get my user id that is saved in the context of the application I can’t reach the content in the messageArrived method of the MqttCallback interface. I want to take that message and insert into my database along with my user id.
The other solution that I’ve thinking of is that when the app is running receive the message in a topic and show in an html page.
This is my interface implementation. I’m implementing the methods of the MqttCallback interface. When I publish a message in my topic (test/topic) I receive the message in the messageArrived method.
But the method is a void method and I cannot get that message and return it in my html page.
For the other hand if I try to get my user data saved in my spring context in that method I cannot get that either. I know that is because I’m in another interface implementation method.
But there is any way to read the message and make the method return a String instead of a void? Or is a way to get my user data in that implementation so I can save the message in my DB along with my user Id?
I’ve been thinkin to create some kind of consumer, but I don’t know how to do it with the mqtt dependency I’m using.