Skip to main content

amqp.createbinarymessage(body, properties)

Creates a new AMQP message in binary form




Name Type Description
body String The body of the message
properties Table Optional message properties as defined by the application


An amqpmessage object primed for transmission in binary form (‘AMQP DATA’)


Important Note Agent AMQP functionality is now deprecated and will shortly become unsupported. Any attempt to interact with imp API amqp objects and methods on unregistered development devices or on production devices will generate a runtime error.

If you are using or intend to use Azure IoTHub, we recommend you make use of MQTT instead of AMQP. Please see our Azure IoT Hub integration for more information.

This method creates a new AMQP message and encodes it in binary form for transmission. This contrasts with amqp.createmessage() which creates a new message that is encoded as a UTF-8 string.

The method is provided because some AMQP brokers are unable to deserialize JSON from a UTF-8 string (‘AMQP VALUE’, the default type) and require that the data be encoded as binary (‘AMQP DATA’) format in the AMQP packets. For example, Azure Stream Analytics returns the error message, “Could not deserialize the input event as Json...”, if you attempt to send JSON encoded as UTF-8.

In such cases you should create your serialized JSON string from a table using http.jsonencode(), and then create your message with amqp.createbinarymessage() rather than amqp.createmessage().

If the optional properties parameter is supplied, it will be used to construct the message. The keys which make up the properties table are application specific. For example, communicating with Microsoft’s Azure IoT Hub AMQP broker requires three properties keys and accompanying values for authentication: operation, type and name. The properties table keys must always be strings, and their values can only be of the following types: Integer, Float, Boolean or String. Passing in any other types is not currently supported, and an attempt will be made to convert them to a string.

Messages, once created, are immutable. If you need to update a message, you should create a new one with updated body and, optionally, properties data.