Asynchronous requests on CoAP resources

For every synchronous request there are asynchronous variants available. These do not return the CoAP response to the request issued. Instead handling the response is delegated to a handler. Besides that, the request is issued the same way the synchronous message-processor do. By using a handler the responses can be processed in another Mule-flow than where the request is made. Also the responses of many different requests can be processed by one and the same flow, by using the same handler. This can be useful when the processing of responses of a large number of different IoT devices needs to be centralised.

In the example below a Get request is issued, delegating the handling of the response.


In the example below a Put request is issued, delegating the handling of the response.


In the example below a Post request is issued, delegating the handling of the response.


In the example below a Delete request is issued, delegating the handling of the response.


The responses on asynchronous requests are processed by the Mule-flow that has configured the <coap-client:handle-response/> message-source, with corresponding handlerName attribute. Also the handler and asynchronous message-processor must reference the same coap-client configuration. If there is not a matching handler an exception will occur during initialisation of the Mule application.

The example below shows a handler that logs the characteristics of the originating request and checks whether the responses report success.