CoAP clients can observe resources when the observe
flag is set on the resource concerned in the server configuration. For every observing
client the server will maintain a so called relation to be able to
send the client an update when the resource state is changed. The CoAP Server connector
can be notified of a state change by using the message-processor
<coap-server:resource-changed/>
. The uri attribute of this
specifies which resource was changed. A wildcard can be used to address multiple
resources.
For every changed resource and relation pair a GET request will be issued ( in fact the original request that initiated the observe-relation is repeated) . This request will passed through to the Mule flow with the appropriate listener. The flow can process this request as if a normal GET request is received.
In the example below all resources contained by alphabet have changed. Issuing the resource-changed will trigger coap-serverFlow1 from the Example 2, “Listen example” multiple times, depending on the number of child-resources of alphabet and the number of clients that observe these.
<flow name="coap-serverFlow2"> ... <coap-server:resource-changed uri="/alphabet/*" config-ref="CoAP_Server_Configuration"/> ... </flow>