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.
The amqp object provides the agent with the ability to send and receive messages using AMQP (Advanced Messaging Queue Protocol). For example, the IoT Hub component of Microsoft‘s Azure cloud infrastructure service uses AMQP for message transfer between IoT devices. amqp supports AMQP 1.0 and above; earlier versions of the protocol are not supported.
For more information on AMQP, please see Wikipedia.
Electric Imp has published a Squirrel library to simplify the interaction between agents and Microsoft’s Azure IoT Hub AMQP broker — please see the library documentation for more information.
For a series of step-by-step walkthroughs to guide you through interacting with Microsoft’s Azure IoT Hub AMQP broker, please see the examples included in our GitHub repo.
AMQP communications are mediated by a number of interrelated imp API objects in addition to amqp:
AMQP operation is currently limited to ensure performance and stability is maintained for all users. Each agent is therefore restricted to:
If any of these limits are exceeded, Squirrel will report one of the following errors, as appropriate:
max connection limit reached in amqp.openconnection(url, callback)
max session limit reached in amqpconnection.opensession(url, callback)
max link limit reached in amqpsession.opensender(url, callback)
max link limit reached in amqpsession.openreceiver(url, callback)
The number of messages you can can issue is also rate-limited. You have credit for 40 messages. As these are used they regenerate at the rate of two credits per second, up to the maximum of 40. This allows you to issue 120 messages in 60 seconds, and issue up to 40 at any one time.
If this rate is exceeded, Squirrel will report the following error:
message rate exceeded in amqptransfer.sendasync(callback).
The amqp object also has the following deprecated member methods, which should not be used in new code, but are documented here as an aid to understanding and migrating old code: