Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] how to publish a .txt or pdf etc through MQTT

Hi Peiyuan,
 
That's correct, you need to take your file, convert it to a byte array and then publish that as your message.
I'm not aware of any tutorial out there, however Google is your friend. I'd suggest searching along the lines of "Java file to byte array" or asking on a Java specific forum.
 
The subscription QoS defines the level at which incoming messages will be delivered. For instance if a Message is sent to the Broker at QoS 2, but the subscriber is QoS 0, then the broker will deliver the message to the subscriber at QoS 0.
 
The Last will message is not required, but if provided will be sent to all subscribers of it's topic if it's client unexpectedly disconnects. It is defined in the connection options when the connection is first initialised.
Useful info here: http://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament
And here: http://www.hivemq.com/blog/mqtt-client-library-encyclopedia-eclipse-paho-java
 
Kind regards,
 
James Sutton
Software Engineer - IoT Foundation - MQTT Open Source Projects
Technical Trojan - Wimbledon Project

Phone: 01962 815438 | Extension: x372454
E-mail: 
Personal Website: www.jsutton.co.uk
Find me on:      
IBM

Hursley Park
HursleySO212JN
United Kingdom
 
IBM United Kingdom Limited Registered in England and Wales with number 741598 Registered office: PO Box 41, North Harbour, Portsmouth, Hants. PO6 3AU
 
 
----- Original message -----
From: fang peiyuan <fang_peiyuan@xxxxxxxxx>
Sent by: paho-dev-bounces@xxxxxxxxxxx
To: General Development Discussions for Paho Project <paho-dev@xxxxxxxxxxx>
Cc:
Subject: [paho-dev] how to publish a .txt or pdf etc through MQTT
Date: Thu, Oct 22, 2015 4:55 AM
 
hi this is peiyuan, i got a reply from james that we are able to publish .txt or dpdf but i still do not get it.
 
Quotes (JAMES)
All you need to do is get a byte array of the data you want to send, publish it and then convert that byte array back into the correct format in your subscriber.
 
For example: if i am send a data.txt through mqtt (language i am using is java)
 
i need to buffer read all the data inside the data.txt and then store it in a variable for example a btye arrray? before sending it as payload 
 
Is there any tutorial or guide that i can follow to learn how to publish file or .txt through MQTT
 
lastly i had a question regarding to subscriber, why do subscriber need a QoS and also had to write the code for the Last will message?
 
for the last will  message basic on my understanding it is used when the user is disconnect due to network breakdown etc
 
hence can i write the source code for last will message 
 
if (!client.disconnect 
{    
    last will message 
}
 
if there is any tutorial i can had a look and learn from it 
 
thank you 
peiyuan
 
 
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev
 


Back to the top