You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 5 Next »
This server-side API class provides methods to generate and send messages to an external queue based on RabbitMQ.
Use this method to return error messages if an error occurred while sending the messages.
Return:
Example:
const rabbitMq = new SimpleExternalRabbitMQ('nofication-service'); const payload = { userIDs: [2344, 7444], message: "Hello!" } ss.info(rabbitMq.publishMessage('push-notifications', JSON.stringify(payload), {ContentType: "application/json", Headers: {"X-Source": "simple"}}).getErrors());
This method sends a message to a selected queue.
Maximum message length – 26000 characters.
Parameter(s):
N
This method sends an array of messages to a selected queue.
const rabbitMq = new SimpleExternalRabbitMQ('notification-service'); const messages = [ { userID: 2344, message: "Hello, Ivan" }, { userID: 7444, message: "Hello, Petr" } ]; rabbitMq.publishMultipleMessages( 'push-notifications', messages.map(m => JSON.stringify(m)), { ContentType: "application/json", Headers: { "X-Source": "simple" } } ) ss.info(rabbitMq.getErrors());