1.1.0 • Published 6 years ago

@syolab/google_pubsub v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Google PubSub Client

This is a Google PubSub Client

Installing with npm

npm install @syolab/google_pubsub --save

using in node js

create client

const pubsub = require('@syolab/google_pubsub');
const path = require("path");

post message

const publishConfig = {
    keyFilePath: path.join(__dirname, "jwt.keys.json"),
    topic: 'projects/my-project/topics/my-topic'
}

let message = {
    data: {//message object},
    attributes: {//attibute object}
}

pubsub.publishMessage(message, publishConfig)
    .then(pubSubMessage=>{
        //pubsub_resultId = Id of published message
    });

pull one message

const pullConfig = {
    keyFilePath: path.join(__dirname, "jwt.keys.json"),
    subscription: 'projects/my-project/subscriptions/my-subscription'
}

pubsub.pullMessage(pullConfig)
    .then(message=>{
        // message published
        //ack message:
        let ack = pubsub.ackMessage(message, pullConfig);
        return ack
    })
    .then(ack=>{
        // ack response

    })
1.1.0

6 years ago

1.0.0

6 years ago