From my reading I see that setting MqttConnectOptions.cleansession = false should allow messages sent while the client was closed to be received. In testing I haven't gotten this to work. Everything else works fine for sending and receiving messages.
B4X:
Sub Process_Globals
Private mqtt As MqttClient
Private mytopic As String
Private serializator As B4XSerializator
Dim mo As MqttConnectOptions
....
End sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
mqtt.Initialize("mqtt", "...mybroker address", "...my clientID")
mo.Initialize("username", "password")
mo.CleanSession = False
mqtt.Connect2(mo)
mytopic = "TestTopic/"
...
end sub