submitMessage method
Submits a message to the specified message queue for asychronous processing. After the message is submitted, the routed service defined in your message queue configuration is invoked. This routed service processes the input message and performs necessary tasks defined in its service flow.
The structure of the message (e.g., key-value pairs) is defined by the Start Node of your queue service.
If the client library key is set to enforce session, an active user session is required (e.g., user needs to be logged in) to call this method.
queueNameOrId
The name or id of the message queue.
message
The message payload (JSON object) that will be submitted to the
message queue.
delay
The number of seconds to delay the messages in queue before
dispacthing them to their consuming service
If successful, returns information about the submitted message. You can
use messageId
to check the processing status of your message by
calling getMessageStatus method. In case of an errors, returns the
errors that occurred.
Implementation
Future<APIResponse<MessageInfo>> submitMessage(
String queueNameOrId, Map<String, dynamic> message,
[int? delay]) async {
var res =
await _fetcher.post<Map<String, dynamic>>('/_api/rest/v1/queue', body: {
'queueNameOrId': queueNameOrId,
'message': message,
if (delay != null) 'delay': delay
});
return APIResponse(
errors: res.errors,
data: res.data != null ? MessageInfo.fromJson(res.data!) : null);
}