- Wrapping the code for each event in an onSuccess callback
When you code a messaging application, you code the following events in the following order:
- receive message
- The "First steps, Hello world" application code uses this approach.
- Embedding the application code within HTML mark-up
Here is the source for the previous page, to show how the application code is embedded within HTML mark-up:
Here is some background messaging information for web app developers who are new to messaging:
- Asynchronous and fire-and-forget messaging.
- The MQTT protocol supports assured delivery and fire-and-forget transfers. In the protocol, message delivery is asynchronous: the app passes the message to the client API, and takes no further action to ensure that the message is delivered. This is approach is known as fire-and-forget. When a response is available, it is automatically sent to the app.
- Asynchronous delivery frees up the app from any server connection, and from waiting for messages. The interaction model is like email, but optimized for application programming.
See also the
MQTT protocolsection of An introduction to the MQTT transport for Mobile Messaging & M2M
- An overview of publish and subscribe messaging.
- The provider of information is called a publisher. A publisher supplies information about a subject, without needing to know anything about the applications that are interested in that information. A publisher chooses a topic, which is a container for messages on a specific subject. The publisher then generates each piece of information for that subject as a message, called a publication, and posts it to the associated topic.
- The consumer of information is called a subscriber. A subscriber creates a subscription to a topic that it is interested in. When a new message is posted to topic, the message is forwarded to all subscribers to the topic. Subscribers can make multiple subscriptions and can receive information from many different publishers.
- See also Publish/subscribe messaging
- How subscriptions and topics match up.
- If you are using WebSphere® MQ as your MQTT server, you need to understand how WebSphere MQ specifies topics. In WebSphere MQ, a publisher creates a message, and publishes it with a topic string that best fits the subject of the publication. To receive publications, a subscriber creates a subscription with a pattern matching topic string to select publication topics. The queue manager delivers publications to subscribers that have subscriptions that match the publication topic, and are authorized to receive the publications.
- Typically subjects are organized hierarchically, into topic trees, using the '/' character to create subtopics in the topic string. Topics are nodes in the topic tree. Topics can be leaf-nodes with no further subtopics, or intermediate nodes with subtopics. Subscribers can use wildcards to subscribe to more than one topic at a time. For example, a subscription to /sport/tennis only gets messages posted to the tennis subtopic, whereas a subscription to /sport/# gets messages posted to any subtopic of /sport.
- See also Topics, Topic trees, and Wildcard schemes.