Elemental lowcode development platform.
The messaging service allows you to access the messaging system. It provides you with the following methods:
All of these methods support an optional access token argument - if one is not provided then the system will attempt to automatically generate one based upon the calling applications credentials.
These methods are covered in more detail below.
Parameters:
queueName
- string, the name of the queue to add the message tomessage
- object, the message objecttoken
- string, the access token to use to access the API optionalAttempts to add the given message into the queue. This method returns a promise that can fail. When it is successful it will return the ID of the newly generated message.
This can be called from your controllers like so:
module.exports = {
events : {
load : (event) => {
return this.messagingService.queueMessage(
"myQueue",
{
hello : "world"
}
).then((id) => {
console.log(id);
}).catch((err) => {
...
});
}
}
};
Parameters:
queueName
- string, the name of the queue to queryid
- string, the unique identifier for the messagetoken
- string, the access token to use to access the API optionalAttempts to fetch the message identified from the queue. This method returns a promise that can fail. When it is successful it will return the message object.
This can be called from your controllers like so:
module.exports = {
events : {
load : (event) => {
return this.messagingService.getMessage(
"myQueue",
"05749898-74a0-47e1-b10d-5acf29d040c4"
).then((message) => {
if (message.status === 'COMPLETE') {
...
} else {
...
}
}).catch((err) => {
...
});
}
}
};
Parameters:
queueName
- string, the name of the queue to queryid
- string, the unique identifier for the messagetoken
- string, the access token to use to access the API optionalAttempts to delete the message identified from the queue. This method returns a promise that can fail.
This can be called from your controllers like so:
module.exports = {
events : {
load : (event) => {
return this.messagingService.deleteMessage(
"myQueue",
"05749898-74a0-47e1-b10d-5acf29d040c4"
).then(() => {
...
}).catch((err) => {
...
});
}
}
};