MQTT - AppDaddy-Software-Solutions-Inc/framework-markup-language GitHub Wiki
<MQTT/> : DataSource
The MQTT
Datasource is a direct link to Active MQ. This can be used to subscribe to, access and send messages to specific topics. The Datasource uses all of its base widget properties and transforms such as FILTER. For more information on Active MQ and MQTT, visit https://activemq.apache.org/.
The [MQTT
] Datasource is used to listen to, read, and write to ActiveMQ Streams. It uses the same Properties
as Datasources
. System wide messages can be broadcast across multiple templates by placing the MQTT broker at the root template ie. MAIN.xml. Elements in the posting body are converted to a table and can be FILTERED.
- To message users, admins, and interface with active mq.
- To alert users using system wide messages.
- The MQTT widget uses only non-durable subscriptions.
- A user must be connected to the network to be subscribed.
- Body and Topic are the only automatically added bindables.
Name | Type | Default | Description | Req |
---|---|---|---|---|
id | string | null | The id of the widget used for databinding. | ✔ |
subscriptions | string, string, ... | null | A comma seperated list of subscription names to connect to | ✔ |
username | string | null | Username credentials to use for connection | |
password | string | null | Password credentials to use for connection | |
autoexecute | bool | true | If the widget will fire when the template is first opened or on url change | |
status | string | idle |
The status of the broker, returns error , success or idle . |
|
statusmessage | string | null | Returns a status message (usually from the response on an exception ). | |
statuscode | string | null | Returns the http status code. |
Name | Type | Default | Description | Req |
---|---|---|---|---|
data | List of item where item is a Map<String, String> or another List of item
|
If the response is encoded as valid json or xml it is deserialized and addressable using DOTNOTATION
|
||
queueType | string | replace |
replace , lifo , fifo , append , prepend . Defines the data aggregation strategy for data returned from initial and subsequent calls. replace (default) replaces all data after each subsequent call. lifo (last in first out), fifo (first in first out), append and prepend are all used in conjunction with the maxrecords attribute |
|
maxrecords | int | 10000 | The maximum size data can grow to. This works in concert with type
|
|
root | string | The root tag that defines the repeatable items in data . This can be a nested field. If not specified, the list is segmented by the first repeatable element found in the data set |
||
ttl | int(s,m,h) | 0s |
Time to Live caches data in the local persistent HIVE database for the period specified. This saves requerying data that changes infrequently |
|
rowcount | int | 0 | The number of records in data
|
Name | Type | Description |
---|---|---|
clear() | Clears data . Invoked in any EVENT string using <id>.clear() |
|
add(jsonOrXml, index) | string, int | Deserializes the jsonOrXml string and adds it to the end of data or at position index if specified. Invoked in any EVENT string using <id>.add(jsonOrXml, index) |
remove(index) | int | Removes the last item from data or from position index if specified. Invoked in any EVENT string using <id>.remove(index) |
reverse() | Reverses data . Invoked in any EVENT string using <id>.reverse() |
Events :: datasource
Name | Type | Default | Description | Req |
---|---|---|---|---|
onmessage | string | null | The string of events the broker will execute on each and every message received | |
onsuccess | string | null | The string of events the broker will execute when the connection is closed. | |
onconnected | string | null | The string of events the broker will execute when the connection is successfully opened | |
ondisconnected | string | null | The string of events the broker will execute when the connection is successfully closed | |
onerror | string | null | The string of events the broker will execute when a connection error is detected | |
onsubscribed | string | null | The string of events the broker will execute when a subscription is successfully opened | |
onunsubscribed | string | null | The string of events the broker will execute when a subscription is closed | |
onpublished | string | null | The string of events the broker will execute when a message has been successfully written to the subscription |
<MQTT id="DB1" method="read" url=":61614/chat" type="append"/> <!--This is a subscription listening to the chat topic-->
<MQTT id="PB1" method="write" body="{newmsg}" url=":61614/chat">
</MQTT> <!--This is a subscription to post to the chat topic-->
These are two MQTT widgets using read and write, showing how to call the widget.
<MQTT id="DB1" url="mqtt://appdaddy.co:61614/chat" type="append"/> <!--This is a subscription listening to the chat topic-->
<MQTT id="PB1" url="mqtt://appdaddy.co:61614/chat">
<BODY>
<MQ>
<from>
{SYSTEM.username}
</from>
<message>
{newmsg}
</message>
</MQ>
</BODY>
</MQTT> <!--This is a subscription to post to the chat topic-->
<COLUMN>
<BOX width="100%" height="50%">
<LIST data="DB1" height="80%">
<ITEM>
<COL>
<PADDING all="10">
<TEXT label="{topic}" color="black" size="11"/>
<TEXT value="{message}" color="black" size="11"/>
</PADDING>
</COL>
</ITEM>
</LIST>
</BOX>
<BOX width="100%">
<INPUT hint="new message" id="newmsg" lines="6" width="100%"/>
<BUTTON label="Send" onclick="PB1.start();newmsg.set('')" color="grey"/>
</BOX>
</COLUMN>
</TEMPLATE>
This is an example of a live chat style template, where a user can send and receive messages to a topic.
### Other Widgets You May Find Useful
- [DataSource](./DataSource)