Implements mqtt publisher and listener