message-mover
v1.0.0
Published
Message mover to GCP pubsub
Downloads
4
Readme
message-mover
This package contains a Javascript function to send messages to GCP PubSub.
Table of Contents
Installation
npm install message-mover
Features
In this package you will find the following features:
SendMessage
This function publish a message to GCP PubSub.
Usage
const messageMover = require('message-mover');
// some async function to use
const callSendMessage = async () => {
// Object with all the PubSub parameters needed to send a message
const psObject = {
// Required fields
PUBSUB_PROJECT_ID: process.env.PUBSUB_PROJECT_ID,
PUBSUB_CLIENT_EMAIL: process.env.PUBSUB_CLIENT_EMAIL,
PUBSUB_PRIVATE_KEY: process.env.PUBSUB_PRIVATE_KEY,
TOPIC_NAME: process.env.TOPIC_NAME,
MESSAGE_ENTITY_TYPE: process.env.MESSAGE_ENTITY_TYPE,
MESSAGE_COUNTRY: process.env.MESSAGE_COUNTRY,
MESSAGE_COMMERCE: process.env.MESSAGE_COMMERCE,
MESSAGE_BUSINESS_UNIT: process.env.MESSAGE_BUSINESS_UNIT,
MESSAGE_DOMAIN: process.env.MESSAGE_DOMAIN,
MESSAGE_CAPABILITY: process.env.MESSAGE_CAPABILITY,
// Optional fields, if not defined, will be used with the default values
MESSAGE_VERSION: '1.0',
MESSAGE_EVENT_TYPE: 'notifyNewRecord',
MESSAGE_CHANNEL: 'Async-PubSub',
MESSAGE_MIME_TYPE:'application/json'
};
// Array with data object that contains their own id
const dataList = [{ id: 1, data: { field_1: XXX, ..., field_N: YYY } }];
await messageMover.sendMessage(psObject, dataList).then((resp) => {
console.log(resp);
});
};
callSendMessage();
This function additionally validates the input parameters to ensure that the message could be sent correctly.
Release notes
1.0.X
This version contains the following features:
- SendMessage