MQTT (Message Queuing Telemetry Transport) is a messing protocol based on publish-subscribe method. Device hosting MQTT message in and out is called the broker. Like a real broker, it hosts the exchange between publishers (sellers) and subscribers (buyers). No money changes hands those. There are plenty of tutorials for this.
If you want to know to get start on Raspberry from the beginning, browse and have a look at this one.
sudo apt-get install mosquitto mosquitto-clients
mosquitto_sub -h localhost -t "yourtopic" mosquitto_pub -t "yourtopic" -h localost -m "say something"
You should see the "say something" shows up on the first terminal. Walah! It works.
The "#" could be use to listen to any topic, replace "yourtopic" by "#"
cd ~ mosquitto_passwrd -c pwfile mqtt_user
sudo nano /etc/mosquitto/mosquitto.conf
allow_anonymous false password_file /home/pi/pwfile
sudo systemctl restart mosquitto
mosquitto_sub -h localhost -t "yourtopic" -u "mqtt_user" -P "123456" mosquitto_pub -h localhost -t "yourtopic" -u "mqtt_user" -P "123456" -m "is this secured?"
Refuse connection without the password, yes, that is what we want.
and connected to the topic with a right password.
I found these references are good to have a look. I learned something from these two reference as I writing this.
The MQTT broker should be ready now, check the status by
sudo systemctl status mosquitto. Next, we will prepare a dash terminal to push the message to MQTT broker.