MQ Telemetry globalization
The message payload in the MQTT v3
protocol is encoded as byte-array. Generally, applications handling text create the message payload
in UTF-8
. The telemetry channel describes the message payload as
UTF-8
, but does not do any code page conversions. The publication topic string must
be UTF-8
.
The application is responsible for converting alphabetic data to the correct code page and numeric data to the correct number encoding.
The MQTT
Java client has a convenient
MqttMessage.toString method. The method treats the message payload as being
encoded in the local platform default character set, which is generally UTF-8
. It
converts the payload to a Java String. Java has a String method, getBytes that
converts a string into a byte array encoded using the local platform default character set. Two
MQTT
Java programs exchanging text in the message
payload, between platforms with the same default character set do so easily and efficiently in
UTF-8
.
If the default character set of one of the platforms is not UTF-8
, then the
applications must establish a convention for exchanging messages. For example, the publisher
specifies conversion from a string to UTF-8
using the
getBytes("UTF8") method. To receive the text of a message, the subscriber assumes
that the message is encoded in the UTF-8
character set.
The telemetry (MQXR) service describes the encoding of all incoming publications from MQTT clients messages as being UTF-8
. It
sets MQMD.CodedCharSetId to UTF-8
, and
RFH2.CodedCharSetId
to MQCCSI_INHERIT
; see Integration of MQ Telemetry with queue managers. The format of the publication is set to MQFMT_NONE
, so no
conversion can be performed by channels, or by MQGET.